diff options
| author | Hauke Mehrtens | 2026-04-12 22:06:32 +0000 |
|---|---|---|
| committer | Hauke Mehrtens | 2026-05-23 00:46:24 +0000 |
| commit | 4b274055ede3d58ceaf2ddb21bd20bcb3d26532f (patch) | |
| tree | a21224b25a98ebda6c1dd204067e940fb893586d | |
| parent | 3cc98db1a422dcf560f2d6347fd410f17565a89d (diff) | |
| download | ubus-4b274055ede3d58ceaf2ddb21bd20bcb3d26532f.tar.gz | |
libubus: fix NULL dereference on OOM in ubus_queue_msg
calloc_a() can return NULL under memory pressure. The returned pointer
was used immediately without a check, causing a NULL dereference crash.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Link: https://github.com/openwrt/ubus/pull/20
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
| -rw-r--r-- | libubus.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -74,6 +74,10 @@ out: return err; } +/* + * Note: any SCM_RIGHTS fd attached to the original message is not propagated + * to the queued copy — the caller must close it (or hand it off) separately. + */ static void ubus_queue_msg(struct ubus_context *ctx, struct ubus_msghdr_buf *buf) { @@ -81,6 +85,8 @@ 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) + return; pending->hdr.data = data; memcpy(&pending->hdr.hdr, &buf->hdr, sizeof(buf->hdr)); |