]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Add printf NULL checks to silence static analyzer
authorSrinivas Girigowda <sgirigow@qca.qualcomm.com>
Thu, 28 Aug 2014 15:25:32 +0000 (18:25 +0300)
committerJouni Malinen <j@w1.fi>
Thu, 28 Aug 2014 15:25:32 +0000 (18:25 +0300)
Add NULL checks to take care of issues reported by static analyzer tool
on potentially using NULL with printf format %s (which has undefined
behavior even though many compilers end up printing "(null)").

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
hostapd/hostapd_cli.c
hostapd/main.c

index 1c4a84c6532f61d49c7dd428f929b5b153cb3f97..09b7284e5635796f81805cfea54aa7fc52130741 100644 (file)
@@ -844,6 +844,8 @@ static int hostapd_cli_cmd_interface(struct wpa_ctrl *ctrl, int argc,
        hostapd_cli_close_connection();
        os_free(ctrl_ifname);
        ctrl_ifname = os_strdup(argv[0]);
+       if (ctrl_ifname == NULL)
+               return -1;
 
        if (hostapd_cli_open_connection(ctrl_ifname)) {
                printf("Connected to interface '%s.\n", ctrl_ifname);
index a9d7da5115d7c49444cd2b9277e544955174a8f4..a9d91b9408de0187eb6452b3f5da018e5b3bba77 100644 (file)
@@ -97,14 +97,15 @@ static void hostapd_logger_cb(void *ctx, const u8 *addr, unsigned int module,
        else if (hapd && hapd->conf)
                os_snprintf(format, maxlen, "%s:%s%s %s",
                            hapd->conf->iface, module_str ? " " : "",
-                           module_str, txt);
+                           module_str ? module_str : "", txt);
        else if (addr)
                os_snprintf(format, maxlen, "STA " MACSTR "%s%s: %s",
                            MAC2STR(addr), module_str ? " " : "",
-                           module_str, txt);
+                           module_str ? module_str : "", txt);
        else
                os_snprintf(format, maxlen, "%s%s%s",
-                           module_str, module_str ? ": " : "", txt);
+                           module_str ? module_str : "",
+                           module_str ? ": " : "", txt);
 
        if ((conf_stdout & module) && level >= conf_stdout_level) {
                wpa_debug_print_timestamp();