[OpenWrt-Devel,iwinfo] nl80211: fix not terminated string in get_countrylist
diff mbox

Message ID 1439971011-4599-1-git-send-email-alejandro.enrique@fon.com
State Superseded
Headers show

Commit Message

Alejandro Enrique Aug. 19, 2015, 7:56 a.m. UTC
nl80211_get_countrylist function was not appending the terminating
NULL character to the ccodes returned

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

Patch
diff mbox

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));