summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2016-02-01 10:56:21 +0100
committerFelix Fietkau <nbd@openwrt.org>2016-02-01 11:09:57 +0100
commit2d38e935ec6d5ad0cd3890fde6c2538f035186eb (patch)
tree3c97aaaaa07606edbf07b0f7d30e1d530ac481ba
parent2475541608efec919ad3cbd0613f0f51fdbd50fd (diff)
proto-shell: Fix possible segfault
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
-rw-r--r--proto-shell.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/proto-shell.c b/proto-shell.c
index 8a3ff69..25dec00 100644
--- a/proto-shell.c
+++ b/proto-shell.c
@@ -708,6 +708,8 @@ proto_shell_add_host_dependency(struct proto_shell_state *state, struct blob_att
return UBUS_STATUS_PERMISSION_DENIED;
dep = calloc(1, sizeof(*dep) + strlen(ifname) + 1);
+ if (!dep)
+ return UBUS_STATUS_UNKNOWN_ERROR;
if (!host[0] && ifname[0]) {
dep->any = true;
@@ -834,6 +836,9 @@ proto_shell_attach(const struct proto_handler *h, struct interface *iface,
struct proto_shell_state *state;
state = calloc(1, sizeof(*state));
+ if (!state)
+ return NULL;
+
INIT_LIST_HEAD(&state->deps);
state->config = malloc(blob_pad_len(attr));