diff options
author | Felix Fietkau <nbd@nbd.name> | 2022-05-15 13:42:56 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2022-05-15 13:42:58 +0200 |
commit | d2223ef9da7172a84d1508733dc58840e1381e3c (patch) | |
tree | 412d4bd8a447290216975fc0c85156bbaf7b2845 | |
parent | cfa372ff8aed8257465adb5445f43656ace2d615 (diff) | |
download | libubox-d2223ef9da7172a84d1508733dc58840e1381e3c.tar.gz |
blobmsg: work around false positive gcc -Warray-bounds warnings
Using the return value of blobmsg_name as input argument to strcpy can lead
to warnings like these:
error: 'strcpy' offset 6 from the object at 'cur' is out of the bounds of referenced subobject 'name' with type 'uint8_t[]' {aka 'unsigned char[]'} at offset 6 [-Werror=array-bounds]
Fix this by replacing hdr->name with the equivalent hdr + 1
Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r-- | blobmsg.h | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -62,7 +62,7 @@ static inline void blobmsg_clear_name(struct blob_attr *attr) static inline const char *blobmsg_name(const struct blob_attr *attr) { struct blobmsg_hdr *hdr = (struct blobmsg_hdr *) blob_data(attr); - return (const char *) hdr->name; + return (const char *)(hdr + 1); } static inline int blobmsg_type(const struct blob_attr *attr) |