fix(nimble): Fix vulnerabilities in NimBLE examples

This commit is contained in:
Shreeyash
2026-02-19 10:18:38 +05:30
committed by Rahul Tank
parent 1a2b081be3
commit ba1360baef
43 changed files with 872 additions and 300 deletions
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@@ -152,9 +152,12 @@ print_adv_fields(const struct ble_hs_adv_fields *fields)
}
if (fields->name != NULL) {
assert(fields->name_len < sizeof s - 1);
memcpy(s, fields->name, fields->name_len);
s[fields->name_len] = '\0';
size_t copy_len = fields->name_len;
if (copy_len >= sizeof(s)) {
copy_len = sizeof(s) - 1;
}
memcpy(s, fields->name, copy_len);
s[copy_len] = '\0';
MODLOG_DFLT(DEBUG, " name(%scomplete)=%s\n",
fields->name_is_complete ? "" : "in", s);
}