mirror of
https://github.com/liquidraver/ZephCore.git
synced 2026-09-01 20:09:17 +00:00
bound AdvertDataParser name copy to _name size (helpers audit)
This commit is contained in:
@@ -110,3 +110,4 @@ UPLINK_AUDIT_INDEX.md
|
||||
GPS_AUDIT_INDEX.md
|
||||
UI_AUDIT_INDEX.md
|
||||
RADIO2_AUDIT_INDEX.md
|
||||
MISC_AUDIT_INDEX.md
|
||||
|
||||
@@ -62,6 +62,13 @@ AdvertDataParser::AdvertDataParser(const uint8_t app_data[], uint8_t app_data_le
|
||||
|
||||
if (_flags & ADV_NAME_MASK) {
|
||||
int nlen = app_data_len - i;
|
||||
/* Self-defense: callers clamp app_data_len to MAX_ADVERT_DATA_SIZE
|
||||
* today, but don't trust that — _name is MAX_ADVERT_DATA_SIZE and the
|
||||
* NUL goes at _name[nlen], so bound nlen to sizeof(_name)-1 or a
|
||||
* malformed/oversized advert would overflow this stack object. */
|
||||
if (nlen > (int)sizeof(_name) - 1) {
|
||||
nlen = (int)sizeof(_name) - 1;
|
||||
}
|
||||
if (nlen > 0) {
|
||||
memcpy(_name, &app_data[i], nlen);
|
||||
_name[nlen] = 0;
|
||||
|
||||
Reference in New Issue
Block a user