[OpenWrt-Devel] [PATCH] [rpcd] iwinfo: zero out ccode buffer since library doesn't

Denis Osvald denis.osvald at sartura.hr
Thu Jun 2 11:06:30 EDT 2016


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 at sartura.hr>
---
 iwinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/iwinfo.c b/iwinfo.c
index 325c07a..b24d0f5 100644
--- 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;
-- 
2.8.2
_______________________________________________
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