session: Fix crash when the UCI option 'password' or 'username' is missing
[project/rpcd.git] / session.c
index a11e3ab524345c60dbf0fb938e53216efc28df41..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;
 
@@ -1332,7 +1338,7 @@ int rpc_session_api_init(struct ubus_context *ctx)
        };
 
        static struct ubus_object_type session_type =
-               UBUS_OBJECT_TYPE("luci-rpc-session", session_methods);
+               UBUS_OBJECT_TYPE("rpcd-plugin-session", session_methods);
 
        static struct ubus_object obj = {
                .name = "session",