From e82dac4b2d8ae2fa8de0cd90ec03ad6ec764584d Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Fri, 17 Mar 2023 15:19:09 -0500 Subject: [PATCH] station: Fix potential buffer overflow Use a more appropriate printf conversion string in order to avoid unnecessary implicit conversion which can lead to a buffer overflow. Reasons similar to commit: 98b758f8934a ("knownnetworks: fix printing SSID in hex") --- src/station.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/station.c b/src/station.c index 8688eaa7..d5650a29 100644 --- a/src/station.c +++ b/src/station.c @@ -368,8 +368,8 @@ static const char *iwd_network_get_path(struct station *station, netdev_get_path(station->netdev)); for (i = 0; ssid[i] && pos < sizeof(path); i++) - pos += snprintf(path + pos, sizeof(path) - pos, "%02x", - ssid[i]); + pos += snprintf(path + pos, sizeof(path) - pos, "%02hhx", + ssid[i]); snprintf(path + pos, sizeof(path) - pos, "_%s", security_to_str(security));