session: Fix crash when the UCI option 'password' or 'username' is missing master
authorIssamHamdi <ih@simonwunderlich.de>
Tue, 28 May 2024 13:58:29 +0000 (15:58 +0200)
committerDaniel Golle <daniel@makrotopia.org>
Tue, 28 May 2024 17:03:57 +0000 (18:03 +0100)
Add a check in 'ptr.o' to prevent a crash in the
'if (ptr.o->type != UCI_TYPE_STRING)' statement
when ptr.o is null. This issue occurs due to the
absence of 'password' or 'username' in the login
section of /etc/config/rpcd.

Signed-off-by: IssamHamdi <ih@simonwunderlich.de>
session.c

index c7d9f3202e6beba81e43ccaff2a7f8e3ba18c3bb..195d07dd3780a7e2e93c9254b1af7a137bf864d4 100644 (file)
--- a/session.c
+++ b/session.c
@@ -862,6 +862,9 @@ rpc_login_test_login(struct uci_context *uci,
                if (uci_lookup_ptr(uci, &ptr, NULL, true))
                        continue;
 
+               if (!ptr.o)
+                       continue;
+
                if (ptr.o->type != UCI_TYPE_STRING)
                        continue;
 
@@ -880,6 +883,9 @@ rpc_login_test_login(struct uci_context *uci,
                if (uci_lookup_ptr(uci, &ptr, NULL, true))
                        continue;
 
+               if (!ptr.o)
+                       continue;
+
                if (ptr.o->type != UCI_TYPE_STRING)
                        continue;