diff --git a/README.md b/README.md index cc92f9983..e8853d4c3 100755 --- a/README.md +++ b/README.md @@ -57,7 +57,6 @@ The DSoftBus directory structure is as follows: >**NOTE** > >- The permissions ohos.permission.DISTRIBUTED_DATASYNC and ohos.permission.DISTRIBUTED_SOFTBUS_CENTER are required for remote procedure calls (RPCs) across devices. ->- To make a mobile phone visible to other devices, choose **Settings** > **Super Device** > **This device** > **Visible to**, and select **All nearby devices**. **1. Discovery** @@ -74,14 +73,14 @@ The DSoftBus directory structure is as follows: // Publish information. typedef struct { - int publishId; // Publish ID. - DiscoverMode mode; // Discovery mode. - ExchangeMedium medium; // Medium used for device discovery. - ExchangeFreq freq; // Device discovery frequency. - const char *capability; // Capability of the device that can be discovered. + int publishId; // Publish ID. + DiscoverMode mode; // Publish mode. + ExchangeMedium medium; // Medium used for publishing the service. + ExchangeFreq freq; // Service publishing frequency. + const char *capability; // Capability of the device that can be discovered. unsigned char *capabilityData; // Custom data for service publishing - unsigned int dataLen; // Length of the data. - bool ranging; // Whether to measure the distance. + unsigned int dataLen; // Length of the data. + bool ranging; // Whether to measure the distance. } PublishInfo; // Publish a service. diff --git a/core/common/dfx/hisysevent_adapter/softbus_hisysevt_discreporter.c b/core/common/dfx/hisysevent_adapter/softbus_hisysevt_discreporter.c index 515b345eb..d75c9120a 100644 --- a/core/common/dfx/hisysevent_adapter/softbus_hisysevt_discreporter.c +++ b/core/common/dfx/hisysevent_adapter/softbus_hisysevt_discreporter.c @@ -474,6 +474,16 @@ int32_t SoftbusRecordFirstDiscTime(SoftBusDiscMedium medium, uint64_t costTime) return SOFTBUS_OK; } +static inline uint32_t AddAndCheckOverflowUint32(uint32_t a, uint32_t b) +{ + return (a > UINT32_MAX - b) ? UINT32_MAX : (a + b); +} + +static inline uint64_t AddAndCheckOverflowUint64(uint64_t a, uint64_t b) +{ + return (a > UINT64_MAX - b) ? UINT64_MAX : (a + b); +} + int32_t SoftbusRecordBleDiscDetails(char *moduleName, uint64_t duration, uint32_t repTimes, uint32_t devNum, uint32_t discTimes) { @@ -491,10 +501,11 @@ int32_t SoftbusRecordBleDiscDetails(char *moduleName, uint64_t duration, uint32_ return SOFTBUS_ERR; } } - discDetailNode->devNum += devNum; - discDetailNode->discTimes += discTimes; - discDetailNode->duration += duration; - discDetailNode->repTimes += repTimes; + + discDetailNode->devNum = AddAndCheckOverflowUint32(discDetailNode->devNum, devNum); + discDetailNode->discTimes = AddAndCheckOverflowUint32(discDetailNode->discTimes, discTimes); + discDetailNode->duration = AddAndCheckOverflowUint64(discDetailNode->duration, duration); + discDetailNode->repTimes = AddAndCheckOverflowUint32(discDetailNode->repTimes, repTimes); (void)SoftBusMutexUnlock(&g_discDetailLock); return SOFTBUS_OK; } diff --git a/core/discovery/ble/softbus_ble/src/disc_ble.c b/core/discovery/ble/softbus_ble/src/disc_ble.c index d0fc1e310..5534346dd 100644 --- a/core/discovery/ble/softbus_ble/src/disc_ble.c +++ b/core/discovery/ble/softbus_ble/src/disc_ble.c @@ -497,7 +497,9 @@ static void ProcessDisNonPacket(const BroadcastReportInfo *reportInfo, char rssi add.medium = BLE; if (ProcessHashAccount(foundInfo)) { - DISC_LOGI(DISC_BLE, "start report found device, callCount=%{public}u", callCount++); + DISC_LOGI(DISC_BLE, "start report found device, addrNum=%{public}u, addr[0].type=%{public}u," + "capabilityBitmap=%{public}u, callCount=%{public}u", foundInfo->addrNum, foundInfo->addr[0].type, + foundInfo->capabilityBitmap[0], callCount++); uint32_t tempCap = 0; DeConvertBitMap(&tempCap, foundInfo->capabilityBitmap, foundInfo->capabilityBitmapNum); if (tempCap == 0) {