diff options
| author | Hauke Mehrtens | 2026-04-09 20:24:13 +0000 |
|---|---|---|
| committer | Hauke Mehrtens | 2026-06-18 22:06:51 +0000 |
| commit | 6f6c861173f0ae3546ae2ab9123b05efd661f5f7 (patch) | |
| tree | 61f36f7d9172439643dcd866638a47a427694ebc | |
| parent | 6f01162d29d6c9412f8c98f365a4e861274d5ff7 (diff) | |
| download | libubox-6f6c861173f0ae3546ae2ab9123b05efd661f5f7.tar.gz | |
blobmsg: fix unsigned integer overflow in blobmsg_alloc_string_buffer()
blobmsg_alloc_string_buffer() increments maxlen by 1 to account for
the null terminator. When maxlen is UINT_MAX, this increment wraps
to 0, causing blobmsg_new() to allocate a zero-length payload. A
subsequent write to the returned buffer would then overflow the
blob's allocated space, corrupting adjacent memory.
Add a bounds check before the increment to reject UINT_MAX input.
Link: https://github.com/openwrt/libubox/pull/42
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
(cherry picked from commit 58b6543f1b2521a5d55c5952f69b9ef5ade0f835)
| -rw-r--r-- | blobmsg.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -340,6 +340,8 @@ blobmsg_alloc_string_buffer(struct blob_buf *buf, const char *name, unsigned int struct blob_attr *attr; void *data_dest; + if (maxlen == (unsigned int)-1) + return NULL; maxlen++; attr = blobmsg_new(buf, BLOBMSG_TYPE_STRING, name, maxlen, &data_dest); if (!attr) |