From: Krishna Date: Sun, 15 Jan 2023 19:58:54 +0000 (+0530) Subject: Fix segfault in case of an invalid configuration X-Git-Tag: hostap_2_11~1323 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d31c2b43aab608e2fd7f70dbbf8c34fbd336ad23;p=thirdparty%2Fhostap.git Fix segfault in case of an invalid configuration The RO variable is being assigned before the SSID is NULL checked, so, any invalid configuration leads to a segmentation fault. Fixes: d8d2b3a338a1 ("Implement read-only mode for SSIDs from the additional config (-I)") Signed-off-by: Chaitanya Tata --- diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c index 4d50f44a8..2e4b081e9 100644 --- a/wpa_supplicant/config_file.c +++ b/wpa_supplicant/config_file.c @@ -339,13 +339,13 @@ struct wpa_config * wpa_config_read(const char *name, struct wpa_config *cfgp, while (wpa_config_get_line(buf, sizeof(buf), f, &line, &pos)) { if (os_strcmp(pos, "network={") == 0) { ssid = wpa_config_read_network(f, &line, id++); - ssid->ro = ro; if (ssid == NULL) { wpa_printf(MSG_ERROR, "Line %d: failed to " "parse network block.", line); errors++; continue; } + ssid->ro = ro; if (head == NULL) { head = tail = ssid; } else {