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>
This commit is contained in:
parent
1b835a50aa
commit
180f6b78a2
1 changed files with 4 additions and 4 deletions
|
@ -359,7 +359,7 @@ find_leasefile(struct uci_context *uci, const char *section)
|
||||||
ptr.option = "leasefile";
|
ptr.option = "leasefile";
|
||||||
ptr.o = NULL;
|
ptr.o = NULL;
|
||||||
|
|
||||||
if (uci_lookup_ptr(uci, &ptr, NULL, true))
|
if (uci_lookup_ptr(uci, &ptr, NULL, true) || ptr.o == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (ptr.o->type != UCI_TYPE_STRING)
|
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.option = "ip";
|
||||||
ptr.o = NULL;
|
ptr.o = NULL;
|
||||||
|
|
||||||
if (uci_lookup_ptr(uci, &ptr, NULL, true))
|
if (uci_lookup_ptr(uci, &ptr, NULL, true) || ptr.o == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (ptr.o->type != UCI_TYPE_STRING)
|
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.option = "name";
|
||||||
ptr.o = NULL;
|
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)
|
ptr.o->type == UCI_TYPE_STRING)
|
||||||
n = ptr.o->v.string;
|
n = ptr.o->v.string;
|
||||||
else
|
else
|
||||||
|
@ -1275,7 +1275,7 @@ rpc_luci_get_host_hints_uci(struct reply_context *rctx)
|
||||||
ptr.option = "mac";
|
ptr.option = "mac";
|
||||||
ptr.o = NULL;
|
ptr.o = NULL;
|
||||||
|
|
||||||
if (uci_lookup_ptr(uci, &ptr, NULL, true))
|
if (uci_lookup_ptr(uci, &ptr, NULL, true) || ptr.o == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (ptr.o->type == UCI_TYPE_STRING) {
|
if (ptr.o->type == UCI_TYPE_STRING) {
|
||||||
|
|
Loading…
Reference in a new issue