From 714fbfff438549ed40f451e461eeaa6234ef4370 Mon Sep 17 00:00:00 2001 From: w00644978 Date: Mon, 26 Sep 2022 09:23:01 +0800 Subject: [PATCH] disc & conn modify code check and modify risk function Signed-off-by: w00644978 --- .../softbus_hisysevt_bus_center.c | 18 +++++++++--------- core/discovery/ble/src/disc_ble.c | 1 + core/discovery/manager/src/disc_manager.c | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/core/common/dfx/hisysevent_adapter/softbus_hisysevt_bus_center.c b/core/common/dfx/hisysevent_adapter/softbus_hisysevt_bus_center.c index 3f837a0e1f..bc7d738ac0 100644 --- a/core/common/dfx/hisysevent_adapter/softbus_hisysevt_bus_center.c +++ b/core/common/dfx/hisysevent_adapter/softbus_hisysevt_bus_center.c @@ -175,21 +175,21 @@ static SoftBusEvtReportMsg *GetRateOfSuccessMsg(LnnStatisticData *data) msg->paramArray[EVT_INDEX_ONE].paramType = SOFTBUS_EVT_PARAMTYPE_INT32; if (strcpy_s(msg->paramArray[EVT_INDEX_ONE].paramName, SOFTBUS_HISYSEVT_PARAM_LEN, BUS_CENTER_PARAM_SUCCESS_COUNT) != EOK) { - SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, " strcpy_s param name %s fail", + SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, " strcpy_s param name %s fail", BUS_CENTER_PARAM_SUCCESS_COUNT); break; } msg->paramArray[EVT_INDEX_TWO].paramType = SOFTBUS_EVT_PARAMTYPE_FLOAT; if (strcpy_s(msg->paramArray[EVT_INDEX_TWO].paramName, SOFTBUS_HISYSEVT_PARAM_LEN, BUS_CENTER_PARAM_SUCCESS_RATE) != EOK) { - SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, " strcpy_s param name %s fail", + SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, " strcpy_s param name %s fail", BUS_CENTER_PARAM_SUCCESS_RATE); break; } msg->paramArray[EVT_INDEX_THREE].paramType = SOFTBUS_EVT_PARAMTYPE_INT32; if (strcpy_s(msg->paramArray[EVT_INDEX_THREE].paramName, SOFTBUS_HISYSEVT_PARAM_LEN, BUS_CENTER_PARAM_CONN_TYPE) != EOK) { - SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, " strcpy_s param name %s fail", + SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, " strcpy_s param name %s fail", BUS_CENTER_PARAM_CONN_TYPE); break; } @@ -243,21 +243,21 @@ static SoftBusEvtReportMsg *GetDurationMsg(LnnStatisticData *data) msg->paramArray[EVT_INDEX_ZERO].paramType = SOFTBUS_EVT_PARAMTYPE_INT32; if (strcpy_s(msg->paramArray[EVT_INDEX_ZERO].paramName, SOFTBUS_HISYSEVT_PARAM_LEN, BUS_CENTER_PARAM_AVG_DURATION) != EOK) { - SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, " strcpy_s param name %s fail", + SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, " strcpy_s param name %s fail", BUS_CENTER_PARAM_AVG_DURATION); break; } msg->paramArray[EVT_INDEX_ONE].paramType = SOFTBUS_EVT_PARAMTYPE_INT32; if (strcpy_s(msg->paramArray[EVT_INDEX_ONE].paramName, SOFTBUS_HISYSEVT_PARAM_LEN, BUS_CENTER_PARAM_MAX_DURATION) != EOK) { - SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, " strcpy_s param name %s fail", + SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, " strcpy_s param name %s fail", BUS_CENTER_PARAM_MAX_DURATION); break; } msg->paramArray[EVT_INDEX_TWO].paramType = SOFTBUS_EVT_PARAMTYPE_INT32; if (strcpy_s(msg->paramArray[EVT_INDEX_TWO].paramName, SOFTBUS_HISYSEVT_PARAM_LEN, BUS_CENTER_PARAM_MIN_DURATION) != EOK) { - SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, " strcpy_s param name %s fail", + SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, " strcpy_s param name %s fail", BUS_CENTER_PARAM_MIN_DURATION); break; } @@ -359,21 +359,21 @@ static int32_t MakeFaultEvt(SoftBusEvtReportMsg *msg) msg->paramArray[EVT_INDEX_ZERO].paramType = SOFTBUS_EVT_PARAMTYPE_INT32; if (strcpy_s(msg->paramArray[EVT_INDEX_ZERO].paramName, SOFTBUS_HISYSEVT_PARAM_LEN, FAULT_EVT_BUS_PARAM_ERROR) != EOK) { - SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, " strcpy_s param name %s fail", + SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, " strcpy_s param name %s fail", FAULT_EVT_BUS_PARAM_ERROR); break; } msg->paramArray[EVT_INDEX_ONE].paramType = SOFTBUS_EVT_PARAMTYPE_STRING; if (strcpy_s(msg->paramArray[EVT_INDEX_ONE].paramName, SOFTBUS_HISYSEVT_PARAM_LEN, FAULT_EVT_BUS_PARAM_ERROR_STR) != EOK) { - SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, " strcpy_s param name %s fail", + SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, " strcpy_s param name %s fail", FAULT_EVT_BUS_PARAM_ERROR_STR); break; } msg->paramArray[EVT_INDEX_TWO].paramType = SOFTBUS_EVT_PARAMTYPE_INT32; if (strcpy_s(msg->paramArray[EVT_INDEX_TWO].paramName, SOFTBUS_HISYSEVT_PARAM_LEN, BUS_CENTER_PARAM_CONN_TYPE) != EOK) { - SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, " strcpy_s param name %s fail", + SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, " strcpy_s param name %s fail", BUS_CENTER_PARAM_CONN_TYPE); break; } diff --git a/core/discovery/ble/src/disc_ble.c b/core/discovery/ble/src/disc_ble.c index d6a9900279..54966efc4f 100644 --- a/core/discovery/ble/src/disc_ble.c +++ b/core/discovery/ble/src/disc_ble.c @@ -1014,6 +1014,7 @@ static int32_t RegisterCapability(DiscBleInfo *info, const DiscBleOption *option } } if (memcpy_s(info->capabilityData[pos], CUST_DATA_MAX_LEN, custData, custDataLen) != EOK) { + SoftBusFree(info->capabilityData[pos]); return SOFTBUS_MEM_ERR; } info->capDataLen[pos] = custDataLen; diff --git a/core/discovery/manager/src/disc_manager.c b/core/discovery/manager/src/disc_manager.c index b3298ca9a1..b89df4c386 100644 --- a/core/discovery/manager/src/disc_manager.c +++ b/core/discovery/manager/src/disc_manager.c @@ -1102,13 +1102,13 @@ static IdContainer* CreateIdContainer(int32_t id, const char *pkgName) if (pkgName == NULL) { return container; } - uint32_t nameLen = strlen(pkgName) + 1; + uint32_t nameLen = strlen(pkgName) + 1; container->pkgName = SoftBusCalloc(nameLen); if (container->pkgName == NULL) { SoftBusFree(container); return NULL; } - if (strcpy_s(container->pkgName, nameLen , pkgName) != EOK) { + if (strcpy_s(container->pkgName, nameLen, pkgName) != EOK) { SoftBusLog(SOFTBUS_LOG_DISC, SOFTBUS_LOG_ERROR, "CreateIdContainer strcpy_s fail"); SoftBusFree(container); return NULL;