summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2019-11-02 20:13:00 +0100
committerJo-Philipp Wich <jo@mein.io>2019-11-02 20:14:25 +0100
commit180f6b78a2c3fc169bc56aeb194eb2fe38900124 (patch)
tree9f5c48f4faf68faed0ee4df0b5eaf0c6a4b69bf2
parent1b835a50aabfbfe7d8d16a6d15c853315dc7ba79 (diff)
rpcd-mod-luci: fix crash on not existing uci options
Checking the return value of uci_lookup_ptr() is not enough to ensure that the requested optiomn has actually been found. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--libs/rpcd-mod-luci/src/luci.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libs/rpcd-mod-luci/src/luci.c b/libs/rpcd-mod-luci/src/luci.c
index 04d3a15b7b..245ca636be 100644
--- a/libs/rpcd-mod-luci/src/luci.c
+++ b/libs/rpcd-mod-luci/src/luci.c
@@ -359,7 +359,7 @@ find_leasefile(struct uci_context *uci, const char *section)
ptr.option = "leasefile";
ptr.o = NULL;
- if (uci_lookup_ptr(uci, &ptr, NULL, true))
+ if (uci_lookup_ptr(uci, &ptr, NULL, true) || ptr.o == NULL)
continue;
if (ptr.o->type != UCI_TYPE_STRING)
@@ -1254,7 +1254,7 @@ rpc_luci_get_host_hints_uci(struct reply_context *rctx)
ptr.option = "ip";
ptr.o = NULL;
- if (uci_lookup_ptr(uci, &ptr, NULL, true))
+ if (uci_lookup_ptr(uci, &ptr, NULL, true) || ptr.o == NULL)
continue;
if (ptr.o->type != UCI_TYPE_STRING)
@@ -1266,7 +1266,7 @@ rpc_luci_get_host_hints_uci(struct reply_context *rctx)
ptr.option = "name";
ptr.o = NULL;
- if (!uci_lookup_ptr(uci, &ptr, NULL, true) &&
+ if (!uci_lookup_ptr(uci, &ptr, NULL, true) && ptr.o != NULL &&
ptr.o->type == UCI_TYPE_STRING)
n = ptr.o->v.string;
else
@@ -1275,7 +1275,7 @@ rpc_luci_get_host_hints_uci(struct reply_context *rctx)
ptr.option = "mac";
ptr.o = NULL;
- if (uci_lookup_ptr(uci, &ptr, NULL, true))
+ if (uci_lookup_ptr(uci, &ptr, NULL, true) || ptr.o == NULL)
continue;
if (ptr.o->type == UCI_TYPE_STRING) {