On 6/22/22 20:58, Rosen Penev wrote:
strlen takes non NULL parameters. Found with GCC's -fanalyzer.

Signed-off-by: Rosen Penev <ros...@gmail.com>
---
  blobmsg.c | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/blobmsg.c b/blobmsg.c
index d87d607..bb6c469 100644
--- a/blobmsg.c
+++ b/blobmsg.c
@@ -364,6 +364,8 @@ blobmsg_add_string_buffer(struct blob_buf *buf)
        int len, attrlen;
attr = blob_next(buf->head);
+       if (!attr)
+               return;
        len = strlen(blobmsg_data(attr)) + 1;
attrlen = blob_raw_len(attr) + len;

This NULL check does not make much sense. The blob_next() function looks like this:

static inline struct blob_attr *
blob_next(const struct blob_attr *attr)
{
        return (struct blob_attr *) ((char *) attr + blob_pad_len(attr));
}

It is very unlikely that this value gets NULL, we might check if buf->head is NULL, but I haven't looked into the rest of the code.

Hauke

_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to