From: Jouni Malinen Date: Wed, 1 Feb 2023 16:21:55 +0000 (+0200) Subject: tests: wpa_supplicant config file parsing of an invalid network X-Git-Tag: hostap_2_11~1322 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=047da5fe3a682830f8cf0d8fb23e97bc3160a283;p=thirdparty%2Fhostap.git tests: wpa_supplicant config file parsing of an invalid network 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 --- diff --git a/tests/hwsim/test_wpas_config.py b/tests/hwsim/test_wpas_config.py index 860e80a05..9bae4deb8 100644 --- a/tests/hwsim/test_wpas_config.py +++ b/tests/hwsim/test_wpas_config.py @@ -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")