{
char *ptr1, *ptr2, *ptr3, *ptr4, *ptr5;
- if (addr_str == NULL || addr_str[0] == '\0')
+ if (addr_str == NULL || strlen(addr_str) != 17) {
+ BT_ERR("Invalid address string: %s", addr_str);
return;
+ }
+
+ if (addr_str[2] != ':' || addr_str[5] != ':' ||
+ addr_str[8] != ':' || addr_str[11] != ':' ||
+ addr_str[14] != ':' || addr_str[17] != '\0') {
+ BT_ERR("Invalid MAC format");
+ return;
+ }
addr_hex->addr[0] = strtol(addr_str, &ptr5, 16);
addr_hex->addr[1] = strtol(ptr5 + 1, &ptr4, 16);
bluetooth_gatt_att_data_t resp;
bluetooth_gatt_server_response_params_t param;
+ if (value_length < 0 || value_length >= BLUETOOTH_GATT_ATT_DATA_LENGTH_MAX)
+ return BT_ERROR_INVALID_PARAMETER;
+
memset(&resp, 0x00, sizeof(resp));
memset(¶m, 0x00, sizeof(param));