summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2016-02-01 10:56:26 +0100
committerFelix Fietkau <nbd@openwrt.org>2016-02-01 11:09:57 +0100
commit1fceaa57f9359ab9792cc97aa81ba5af3f5ffca7 (patch)
tree670062e95cca92add7e90ca6dec8816afd5fdc65
parentcf9033dd5ac75cb3c8c2fd55011f3ec5cd4c2371 (diff)
proto: Fix possible segfaults
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
-rw-r--r--proto.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/proto.c b/proto.c
index b91fcde..45eeb4b 100644
--- a/proto.c
+++ b/proto.c
@@ -101,6 +101,9 @@ alloc_device_addr(bool v6, bool ext)
struct device_addr *addr;
addr = calloc(1, sizeof(*addr));
+ if (!addr)
+ return NULL;
+
addr->flags = v6 ? DEVADDR_INET6 : DEVADDR_INET4;
if (ext)
addr->flags |= DEVADDR_EXTERNAL;
@@ -262,6 +265,9 @@ parse_gateway_option(struct interface *iface, struct blob_attr *attr, bool v6)
int af = v6 ? AF_INET6 : AF_INET;
route = calloc(1, sizeof(*route));
+ if (!route)
+ return NULL;
+
if (!inet_pton(af, str, &route->nexthop)) {
interface_add_error(iface, "proto", "INVALID_GATEWAY", &str, 1);
free(route);
@@ -514,6 +520,9 @@ default_proto_attach(const struct proto_handler *h,
struct interface_proto_state *proto;
proto = calloc(1, sizeof(*proto));
+ if (!proto)
+ return NULL;
+
proto->free = default_proto_free;
proto->cb = no_proto_handler;