From c3fa11b88d12c9f931ea0515f3051565d2ff915d Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Sun, 15 Dec 2019 23:10:02 +0000 Subject: Apply awilfox's wpactrl_associate() fixes --- src/libwpactrl/wpactrl_associate.c | 3 ++- src/libwpactrl/wpactrl_networks_parse.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/libwpactrl/wpactrl_associate.c b/src/libwpactrl/wpactrl_associate.c index 59900d6..0f1bd2e 100644 --- a/src/libwpactrl/wpactrl_associate.c +++ b/src/libwpactrl/wpactrl_associate.c @@ -14,9 +14,10 @@ int wpactrl_associate (wpactrl_t *a, char const *ssid, char const *psk, tain_t * if (!wpactrl_addnetwork(a, &id, stamp)) goto err ; } + if (wpactrl_setnetworkoption(a, id, "ssid", ssid, stamp) != WPA_OK) goto err ; if (psk) { - if (wpactrl_setnetworkoption(a, id, "key_mgmt", "WPA-PSK WPA-PSK-SHA256", stamp) != WPA_OK + if (wpactrl_setnetworkoption(a, id, "key_mgmt", "WPA-PSK", stamp) != WPA_OK || wpactrl_setnetworkoption(a, id, "mem_only_psk", "1", stamp) != WPA_OK || wpactrl_setnetworkoption(a, id, "psk", psk, stamp) != WPA_OK) goto err ; } diff --git a/src/libwpactrl/wpactrl_networks_parse.c b/src/libwpactrl/wpactrl_networks_parse.c index 1f7f0e9..79306a2 100644 --- a/src/libwpactrl/wpactrl_networks_parse.c +++ b/src/libwpactrl/wpactrl_networks_parse.c @@ -3,12 +3,14 @@ #include #include #include + #include #include #include #include #include #include + #include static int wpactrl_networks_parse_one (char const *s, size_t len, wpactrl_networks_t *thing, stralloc *sa) @@ -27,10 +29,10 @@ static int wpactrl_networks_parse_one (char const *s, size_t len, wpactrl_networ len = pos ; pos = byte_rchr(s, len - 1, '\t') ; - if (!pos || pos >= len - 1) goto eproto ; + if (pos >= len - 1) goto eproto ; if (wpactrl_bssid_scan(s + pos + 1, sr.bssid) != len - pos - 1) goto eproto ; len = pos ; - + if (!len) len = 1 ; sr.ssid_start = sa->len ; sr.ssid_len = len - 1 ; if (!stralloc_catb(sa, s, len - 1) || !stralloc_0(sa)) return 0 ; -- cgit 1.4.1