knownnetworks: fix potential out of bounds write
If a very long ssid was used (e.g. CJK characters in SSID), it might do out of bounds write to static variable for lack of checking the position before the last snprintf() call.
This commit is contained in:
parent
5e0ff318e7
commit
89309a8621
|
@ -176,7 +176,8 @@ static const char *known_network_get_path(const struct network_info *network)
|
||||||
pos += snprintf(path + pos, sizeof(path) - pos, "%02x",
|
pos += snprintf(path + pos, sizeof(path) - pos, "%02x",
|
||||||
network->ssid[i]);
|
network->ssid[i]);
|
||||||
|
|
||||||
snprintf(path + pos, sizeof(path) - pos, "_%s",
|
if (pos < sizeof(path))
|
||||||
|
snprintf(path + pos, sizeof(path) - pos, "_%s",
|
||||||
security_to_str(network->type));
|
security_to_str(network->type));
|
||||||
path[sizeof(path) - 1] = '\0';
|
path[sizeof(path) - 1] = '\0';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue