diff mbox series

wpa_cli: Don't access uninitialized variables

Message ID 20201019080630.9115-1-andrei.otcheretianski@intel.com
State Accepted
Headers show
Series wpa_cli: Don't access uninitialized variables | expand

Commit Message

Andrei Otcheretianski Oct. 19, 2020, 8:06 a.m. UTC
Don't print potentially uninitialized variables in wpa_ctrl_command_bss().
Some compilers and analyzers may warn about it.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
---
 wpa_supplicant/wpa_cli.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Jouni Malinen Oct. 19, 2020, 9:40 p.m. UTC | #1
Thanks, all three patches applied.
diff mbox series

Patch

diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c
index 51c9642e90..2ac282d979 100644
--- a/wpa_supplicant/wpa_cli.c
+++ b/wpa_supplicant/wpa_cli.c
@@ -3085,7 +3085,8 @@  static int wpa_cli_cmd_dpp_stop_chirp(struct wpa_ctrl *ctrl, int argc,
 
 static int wpa_ctrl_command_bss(struct wpa_ctrl *ctrl, const char *cmd)
 {
-	char buf[512], *pos, *bssid, *freq, *level, *flags, *ssid;
+	char buf[512], *pos, *bssid = NULL, *freq = NULL, *level = NULL,
+		*flags = NULL, *ssid = NULL;
 	size_t len;
 	int ret, id = -1;
 
@@ -3126,7 +3127,9 @@  static int wpa_ctrl_command_bss(struct wpa_ctrl *ctrl, const char *cmd)
 		*pos++ = '\0';
 	}
 	if (id != -1)
-		printf("%s\t%s\t%s\t%s\t%s\n", bssid, freq, level, flags, ssid);
+		printf("%s\t%s\t%s\t%s\t%s\n", bssid ? bssid : "N/A",
+		       freq ? freq : "N/A", level ? level : "N/A",
+		       flags? flags : "N/A", ssid ? ssid : "N/A");
 	return id;
 }