]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: wpa_supplicant config file parsing of an invalid network
authorJouni Malinen <quic_jouni@quicinc.com>
Wed, 1 Feb 2023 16:21:55 +0000 (18:21 +0200)
committerJouni Malinen <j@w1.fi>
Wed, 1 Feb 2023 16:26:35 +0000 (18:26 +0200)
This is a regression test for a NULL pointer dereferencing from commit
d8d2b3a338a1 ("Implement read-only mode for SSIDs from the additional
config (-I)") .

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
tests/hwsim/test_wpas_config.py

index 860e80a056972ed241f14690ec16c21964a165fa..9bae4deb8d8b815702006a49fc164070d98cc236 100644 (file)
@@ -661,3 +661,22 @@ def test_wpas_config_update_without_file(dev, apdev):
     wpas.set("update_config", "1")
     if "FAIL" not in wpas.request("SAVE_CONFIG"):
         raise Exception("SAVE_CONFIG accepted unexpectedly")
+
+def test_wpas_config_file_invalid_network(dev, apdev, params):
+    """wpa_supplicant config file parsing of an invalid network"""
+    config = params['prefix'] + '.conf.wlan5'
+    wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
+    with open(config, "w") as f:
+        f.write("network={\n")
+        f.write("\tunknown=UNKNOWN\n")
+        f.write("}\n")
+    success = False
+    try:
+        wpas.interface_add("wlan5", config=config)
+        success = True
+    except Exception as e:
+        if str(e) != "Failed to add a dynamic wpa_supplicant interface":
+            raise
+
+    if success:
+        raise Exception("Interface addition succeeded with invalid configuration")