diff mbox series

ubusd: handle invoke on event object without data

Message ID 20210702162505.2492190-1-erik.r.karlsson@gmail.com
State Accepted
Delegated to: Daniel Golle
Headers show
Series ubusd: handle invoke on event object without data | expand

Commit Message

Erik Karlsson July 2, 2021, 4:25 p.m. UTC
From: Erik Karlsson <erik.karlsson@genexis.eu>

When a built-in object is invoked with UBUS_ATTR_DATA absent, recv_msg
will be called with NULL as the msg argument and ubusd_forward_event
and ubusd_alloc_event_pattern need to handle this. Otherwise, a
truncated invoke of "send" or "register" on UBUS_SYSTEM_OBJECT_EVENT
that is missing UBUS_ATTR_DATA will cause ubusd to crash with SIGSEGV.

Signed-off-by: Erik Karlsson <erik.karlsson@genexis.eu>
---
 ubusd_event.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/ubusd_event.c b/ubusd_event.c
index ef433f8..15932a9 100644
--- a/ubusd_event.c
+++ b/ubusd_event.c
@@ -63,6 +63,9 @@  static int ubusd_alloc_event_pattern(struct ubus_client *cl, struct blob_attr *m
 	bool partial = false;
 	int len;
 
+	if (!msg)
+		return UBUS_STATUS_INVALID_ARGUMENT;
+
 	blobmsg_parse(evr_policy, EVREG_LAST, attr, blob_data(msg), blob_len(msg));
 	if (!attr[EVREG_OBJECT] || !attr[EVREG_PATTERN])
 		return UBUS_STATUS_INVALID_ARGUMENT;
@@ -209,6 +212,9 @@  static int ubusd_forward_event(struct ubus_client *cl, struct blob_attr *msg)
 	struct blob_attr *attr[EVMSG_LAST];
 	const char *id;
 
+	if (!msg)
+		return UBUS_STATUS_INVALID_ARGUMENT;
+
 	blobmsg_parse(ev_policy, EVMSG_LAST, attr, blob_data(msg), blob_len(msg));
 	if (!attr[EVMSG_ID] || !attr[EVMSG_DATA])
 		return UBUS_STATUS_INVALID_ARGUMENT;