diff mbox series

Fix segfault in case of invalid configuration

Message ID 20230115195854.34014-1-krishna.t@nordicsemi.no
State Accepted
Headers show
Series Fix segfault in case of invalid configuration | expand

Commit Message

Krishna Chaitanya Jan. 15, 2023, 7:58 p.m. UTC
The RO variable is being assigned before the SSID is NULL checked, so,
any invalid configuration leads to a segmentation fault.

Fixes commit d8d2b3a33("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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jouni Malinen Feb. 1, 2023, 4:56 p.m. UTC | #1
On Mon, Jan 16, 2023 at 01:28:54AM +0530, Krishna wrote:
> The RO variable is being assigned before the SSID is NULL checked, so,
> any invalid configuration leads to a segmentation fault.

Thanks, applied.
diff mbox series

Patch

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 {