]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Fix segfault in case of an invalid configuration
authorKrishna <chaitanya.mgit@gmail.com>
Sun, 15 Jan 2023 19:58:54 +0000 (01:28 +0530)
committerJouni Malinen <j@w1.fi>
Wed, 1 Feb 2023 16:24:13 +0000 (18:24 +0200)
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 <chaitanya.tk17@gmail.com>
wpa_supplicant/config_file.c

index 4d50f44a8654dbe40e2d12b009b1aee11158bebf..2e4b081e9a5d9e85ce219e96b03711e249cc8246 100644 (file)
@@ -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 {