check min size for custom data

pull/8738/head
paul-szczepanek-arm 2018-11-19 14:01:26 +00:00 committed by Vincent Coubard
parent e54c0ed1de
commit 062c301a96
1 changed files with 7 additions and 1 deletions

View File

@ -795,11 +795,17 @@ public:
* *
* @retval BLE_ERROR_NONE on success. * @retval BLE_ERROR_NONE on success.
* @retval BLE_ERROR_BUFFER_OVERFLOW if buffer is too small to contain the new data. * @retval BLE_ERROR_BUFFER_OVERFLOW if buffer is too small to contain the new data.
* @retval BLE_ERROR_INVALID_PARAM if size of data is too big too fit in an individual data field. * @retval BLE_ERROR_INVALID_PARAM if size of data is too big too fit in an individual
* data field or the data is too small (must contain
* 2 bytes of manufacturer ID)
*/ */
ble_error_t setManufacturerSpecificData( ble_error_t setManufacturerSpecificData(
mbed::Span<const uint8_t> data mbed::Span<const uint8_t> data
) { ) {
if (data.size() < 2) {
return BLE_ERROR_INVALID_PARAM;
}
return addOrReplaceData(adv_data_type_t::MANUFACTURER_SPECIFIC_DATA, data); return addOrReplaceData(adv_data_type_t::MANUFACTURER_SPECIFIC_DATA, data);
} }