iwinfo: zero out ccode buffer since library doesn't
authorDenis Osvald <denis.osvald@sartura.hr>
Thu, 2 Jun 2016 15:06:30 +0000 (17:06 +0200)
committerJo-Philipp Wich <jo@mein.io>
Sun, 5 Jun 2016 14:05:23 +0000 (16:05 +0200)
Making an ubus call iwinfo countrylist '{"device":"radio0"}' will result
in some entries having garbage uninitialized stack bytes in the "code"
fields.

With this patch we zero-initialize the buffer that libiwinfo writes to,
making it NUL-terminated so that behavior doesn't happen anymore.

Signed-off-by: Denis Osvald <denis.osvald@sartura.hr>
iwinfo.c

index 325c07a1d41c7e99d98eddcd15b6b67483263594..b24d0f53bc37ca813398cac0a0f362db899b3898 100644 (file)
--- a/iwinfo.c
+++ b/iwinfo.c
@@ -588,7 +588,7 @@ rpc_iwinfo_countrylist(struct ubus_context *ctx, struct ubus_object *obj,
        int rv, len;
        char cur[3];
        char iso3166[3];
-       char res[IWINFO_BUFSIZE];
+       char res[IWINFO_BUFSIZE] = {0};
        const char *ccode;
        const struct iwinfo_iso3166_label *l;
        void *c, *d;