[PATCHv2] Return with error when trying to set invalid WEP key length

Saurav Babu saurav.babu at samsung.com
Wed Sep 21 03:33:47 PDT 2016


While trying to set WEP key an invalid key length can be set, but
set command returns "OK". User is unable to know about the invalid WEP
key length. This patch returns "FAIL" so that user can correct WEP key.

Signed-off-by: Saurav Babu <saurav.babu at samsung.com>

v2: Check invalid WEP key length before wpa_config_set() so that existing
functionality of wpa_supplicant to start with configuration file remains
unaffected.
---
 wpa_supplicant/ctrl_iface.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 9543fd1..ec74b6f 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -2991,7 +2991,16 @@ static int wpa_supplicant_ctrl_iface_update_network(
 	char *name, char *value)
 {
 	int ret;
+	int len;
 
+	if (os_strstr(name, "wep_key") != NULL) {
+		/* value is in "" so subtract 2 from length */
+		len = os_strlen(value) - 2;
+		if (len != 5 && len != 13 && len != 16) {
+			wpa_printf(MSG_ERROR, "Invalid WEP key length %d", len);
+			return -1;
+		}
+	}
 	ret = wpa_config_set(ssid, name, value, 0);
 	if (ret < 0) {
 		wpa_printf(MSG_DEBUG, "CTRL_IFACE: Failed to set network "
-- 
1.9.1




More information about the Hostap mailing list