[OpenWrt-Devel] [PATCH] [iwinfo] nl80211: fix not terminated string in get_countrylist

Alejandro Enrique alejandro.enrique at fon.com
Wed Aug 19 03:56:51 EDT 2015


nl80211_get_countrylist function was not appending the terminating
NULL character to the ccodes returned

Signed-off-by: Alejandro Enrique <alejandro.enrique at fon.com>
---
 iwinfo_nl80211.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/iwinfo_nl80211.c b/iwinfo_nl80211.c
index 55bfd0f..8672dd8 100644
--- a/iwinfo_nl80211.c
+++ b/iwinfo_nl80211.c
@@ -2478,8 +2478,8 @@ static int nl80211_get_countrylist(const char *ifname, char *buf, int *len)
 	for (l = IWINFO_ISO3166_NAMES, count = 0; l->iso3166; l++, e++, count++)
 	{
 		e->iso3166 = l->iso3166;
-		e->ccode[0] = (l->iso3166 / 256);
-		e->ccode[1] = (l->iso3166 % 256);
+		snprintf(e->ccode, sizeof(e->ccode), "%c%c",
+			 (l->iso3166 / 256), (l->iso3166 % 256));
 	}
 
 	*len = (count * sizeof(struct iwinfo_country_entry));
-- 
2.1.4
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list