[OpenWrt-Devel] [PATCH] Deal gracefully with allocation failures in a few omitted places.

Juliusz Chroboczek jch at pps.univ-paris-diderot.fr
Thu Jun 25 18:21:48 EDT 2015


---
 libubus.c   | 3 +++
 ubusd_acl.c | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/libubus.c b/libubus.c
index ccaa069..9aae613 100644
--- a/libubus.c
+++ b/libubus.c
@@ -77,6 +77,9 @@ ubus_queue_msg(struct ubus_context *ctx, struct ubus_msghdr_buf *buf)
 	void *data;
 
 	pending = calloc_a(sizeof(*pending), &data, blob_raw_len(buf->data));
+        if (!pending)
+		/* XXX */
+		return;
 
 	pending->hdr.data = data;
 	memcpy(&pending->hdr.hdr, &buf->hdr, sizeof(buf->hdr));
diff --git a/ubusd_acl.c b/ubusd_acl.c
index 3c16114..5ed7b99 100644
--- a/ubusd_acl.c
+++ b/ubusd_acl.c
@@ -207,6 +207,8 @@ ubusd_acl_alloc_obj(struct ubusd_acl_file *file, const char *obj)
 	char *k;
 
 	o = calloc_a(1, sizeof(*o), &k, strlen(obj) + 1);
+        if (!o)
+		return NULL;
 	o->user = file->user;
 	o->group = file->group;
 	o->avl.key = k;
-- 
2.1.4
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list