tests: wpa_supplicant config file parsing of an invalid network

This is a regression test for a NULL pointer dereferencing from commit
d8d2b3a338 ("Implement read-only mode for SSIDs from the additional
config (-I)") .

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
This commit is contained in:
Jouni Malinen 2023-02-01 18:21:55 +02:00 committed by Jouni Malinen
parent d31c2b43aa
commit 047da5fe3a

View 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")