3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-22 13:02:44 +01:00

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:
Jiajie Chen 2023-02-26 14:25:25 +08:00 committed by Denis Kenzior
parent 5e0ff318e7
commit 89309a8621

View File

@ -176,7 +176,8 @@ static const char *known_network_get_path(const struct network_info *network)
pos += snprintf(path + pos, sizeof(path) - pos, "%02x",
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));
path[sizeof(path) - 1] = '\0';