aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/wpa_cli.c
diff options
context:
space:
mode:
authorEytan Lifshitz <eytan.lifshitz@intel.com>2015-01-19 04:57:30 (GMT)
committerJouni Malinen <j@w1.fi>2015-01-20 00:08:58 (GMT)
commit30f459c098ccb3179abc4cfcc54619ccd12fefa6 (patch)
treec72af7aef04f438fc70e050578963aba24365020 /wpa_supplicant/wpa_cli.c
parent414f23d8b930095c96b752cc920c4a69bd35d5a3 (diff)
downloadhostap-30f459c098ccb3179abc4cfcc54619ccd12fefa6.zip
hostap-30f459c098ccb3179abc4cfcc54619ccd12fefa6.tar.gz
hostap-30f459c098ccb3179abc4cfcc54619ccd12fefa6.tar.bz2
wpa_cli: Fix NULL dereference on printf string argument
In wpa_cli_cmd_interface(), try_connection(), and main(), ctrl_ifname may be NULL and could be dereferenced depending on the printf() implementation. Signed-off-by: Eytan Lifshitz <eytan.lifshitz@intel.com>
Diffstat (limited to 'wpa_supplicant/wpa_cli.c')
-rw-r--r--wpa_supplicant/wpa_cli.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c
index d2face0..79619f2 100644
--- a/wpa_supplicant/wpa_cli.c
+++ b/wpa_supplicant/wpa_cli.c
@@ -1577,6 +1577,10 @@ static int wpa_cli_cmd_interface(struct wpa_ctrl *ctrl, int argc, char *argv[])
wpa_cli_close_connection();
os_free(ctrl_ifname);
ctrl_ifname = os_strdup(argv[0]);
+ if (!ctrl_ifname) {
+ printf("Failed to allocate memory\n");
+ return 0;
+ }
if (wpa_cli_open_connection(ctrl_ifname, 1) == 0) {
printf("Connected to interface '%s.\n", ctrl_ifname);
@@ -3743,7 +3747,8 @@ static void try_connection(void *eloop_ctx, void *timeout_ctx)
if (!wpa_cli_open_connection(ctrl_ifname, 1) == 0) {
if (!warning_displayed) {
printf("Could not connect to wpa_supplicant: "
- "%s - re-trying\n", ctrl_ifname);
+ "%s - re-trying\n",
+ ctrl_ifname ? ctrl_ifname : "(nil)");
warning_displayed = 1;
}
eloop_register_timeout(1, 0, try_connection, NULL, NULL);
@@ -4004,7 +4009,8 @@ int main(int argc, char *argv[])
wpa_cli_open_connection(ctrl_ifname, 0) < 0) {
fprintf(stderr, "Failed to connect to non-global "
"ctrl_ifname: %s error: %s\n",
- ctrl_ifname, strerror(errno));
+ ctrl_ifname ? ctrl_ifname : "(nil)",
+ strerror(errno));
return -1;
}