!3693 strcpy函数越界风险修改

Merge pull request !3693 from WANGJINGEN/master
This commit is contained in:
openharmony_ci 2023-05-19 09:05:19 +00:00 committed by Gitee
commit 0b21fe74bf
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 1 additions and 10 deletions

View File

@ -110,7 +110,7 @@ static int32_t ConvertMsgToHiSysEvent(SoftBusEvtReportMsg *msg)
return SOFTBUS_ERR;
}
for (uint32_t i = 0; i < msg->paramNum; i++) {
if (strcpy_s(g_dstParam[i].name, SOFTBUS_HISYSEVT_NAME_LEN, msg->paramArray[i].paramName) != EOK) {
if (strcpy_s(g_dstParam[i].name, MAX_LENGTH_OF_PARAM_NAME, msg->paramArray[i].paramName) != EOK) {
HILOG_ERROR(SOFTBUS_HILOG_ID, "copy param fail");
return SOFTBUS_ERR;
}

View File

@ -1007,11 +1007,6 @@ static int32_t RegisterCapability(DiscBleInfo *info, const DiscBleOption *option
return SOFTBUS_MALLOC_ERR;
}
}
if (custDataLen > CUST_DATA_MAX_LEN) {
DLOGE("custDataLen(%u) larger than CUST_DATA_MAX_LEN", custDataLen);
SoftBusFree(info->capabilityData[pos]);
return SOFTBUS_INVALID_PARAM;
}
if (memcpy_s(info->capabilityData[pos], CUST_DATA_MAX_LEN, custData, custDataLen) != EOK) {
SoftBusFree(info->capabilityData[pos]);
return SOFTBUS_MEM_ERR;

View File

@ -172,10 +172,6 @@ NO_SANITIZE("cfi") int32_t AssembleTLV(BroadcastData *broadcastData, uint8_t dat
/* A helper function for copying TLV value to destination */
static int32_t CopyValue(void *dst, uint32_t dstLen, const void *src, uint32_t srcLen, const char *hint)
{
if (srcLen > dstLen) {
DLOGE("srcLen(%u) > dstLen(%u)", srcLen, dstLen);
return SOFTBUS_INVALID_PARAM;
}
if (memcpy_s(dst, dstLen, src, srcLen) != EOK) {
DLOGE("parse tlv memcpy failed, tlvType: %s, tlvLen: %u, dstLen: %u", hint, srcLen, dstLen);
return SOFTBUS_MEM_ERR;