diff mbox series

[OpenWrt-Devel,libubox,1/3] blobmsg: fix length in blobmsg_check_array

Message ID 20200525151908.3930-1-nbd@nbd.name
State Accepted
Delegated to: Felix Fietkau
Headers show
Series [OpenWrt-Devel,libubox,1/3] blobmsg: fix length in blobmsg_check_array | expand

Commit Message

Felix Fietkau May 25, 2020, 3:19 p.m. UTC
blobmsg_check_array_len expects the length of the full attribute buffer,
not just the data length.
Due to other missing length checks (fixed in the next commit), this did
not show up as a test failure

Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 blobmsg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Rafał Miłecki May 25, 2020, 4:48 p.m. UTC | #1
On 25.05.2020 17:19, Felix Fietkau wrote:
> blobmsg_check_array_len expects the length of the full attribute buffer,
> not just the data length.
> Due to other missing length checks (fixed in the next commit), this did
> not show up as a test failure
> 
> Signed-off-by: Felix Fietkau <nbd@nbd.name>

Tested-by: Rafał Miłecki <rafal@milecki.pl>
diff mbox series

Patch

diff --git a/blobmsg.c b/blobmsg.c
index 59045e1672c8..daaa9fc8444b 100644
--- a/blobmsg.c
+++ b/blobmsg.c
@@ -114,7 +114,7 @@  bool blobmsg_check_attr_len(const struct blob_attr *attr, bool name, size_t len)
 
 int blobmsg_check_array(const struct blob_attr *attr, int type)
 {
-	return blobmsg_check_array_len(attr, type, blob_len(attr));
+	return blobmsg_check_array_len(attr, type, blob_raw_len(attr));
 }
 
 int blobmsg_check_array_len(const struct blob_attr *attr, int type,