]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
WPS: Fix return value when context is not valid
authorPetar Koretic <petar.koretic@sartura.hr>
Wed, 14 May 2014 13:51:04 +0000 (13:51 +0000)
committerJouni Malinen <j@w1.fi>
Thu, 15 May 2014 21:58:48 +0000 (00:58 +0300)
If WPS isn't enabled, hostapd_cli returns 'OK' even though WPS doesn't
get activated because WPS context is not valid:

$ hostapd_cli wps_pbc
Selected interface 'wlan0'
OK

$ hostapd_cli wps_cancel
Selected interface 'wlan0'
OK

Fix this by returning appropriate error when WPS fails to activate:

$ hostapd_cli wps_pbc
Selected interface 'wlan0'
FAIL

$ hostapd_cli wps_cancel
Selected interface 'wlan0'
FAIL

Signed-off-by: Petar Koretic <petar.koretic@sartura.hr>
CC: Luka Perkov <luka.perkov@sartura.hr>
src/ap/wps_hostapd.c

index f165670136f3b233768756eade82df54b17caf76..6f16f50ecdd07e251e57dda6794db343f76dceb9 100644 (file)
@@ -1290,7 +1290,7 @@ static int wps_button_pushed(struct hostapd_data *hapd, void *ctx)
 {
        const u8 *p2p_dev_addr = ctx;
        if (hapd->wps == NULL)
-               return 0;
+               return -1;
        return wps_registrar_button_pushed(hapd->wps->registrar, p2p_dev_addr);
 }
 
@@ -1306,7 +1306,7 @@ int hostapd_wps_button_pushed(struct hostapd_data *hapd,
 static int wps_cancel(struct hostapd_data *hapd, void *ctx)
 {
        if (hapd->wps == NULL)
-               return 0;
+               return -1;
 
        wps_registrar_wps_cancel(hapd->wps->registrar);
        ap_for_each_sta(hapd, ap_sta_wps_cancel, NULL);