session: Fix crash when the UCI option 'password' or 'username' is missing

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>
This commit is contained in:
IssamHamdi 2024-05-28 15:58:29 +02:00 committed by Daniel Golle
parent 8ef4c2587a
commit bcc091d2f1

View file

@ -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;