mmsghdr: workaround -Warray-bounds regression in Red Hat gcc 12/294312/1 accepted/tizen_8.0_unified accepted/tizen_9.0_unified accepted/tizen_unified_dev tizen_8.0 tizen_9.0 accepted/tizen/8.0/unified/20231005.095544 accepted/tizen/9.0/unified/20241030.234342 accepted/tizen/unified/20230616.172420 accepted/tizen/unified/dev/20230726.115421 tizen_8.0_m2_release tizen_9.0_m2_release
authorDmitry V. Levin <ldv@altlinux.org>
Fri, 11 Dec 2020 13:00:00 +0000 (13:00 +0000)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Fri, 16 Jun 2023 03:58:46 +0000 (12:58 +0900)
The version of gcc packaged into Rawhide erroneously produces
the following false positive diagnostics:

mmsghdr.c: In function 'do_recvmmsg':
mmsghdr.c:87:23: error: array subscript 'struct mmsgvec_data[0]' is partly outside array bounds of 'unsigned char[4108]' [-Werror=array-bounds]
   87 |         data->timeout = xstrdup(timeout);
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~

Tested with:
$ gcc --version |head -1
gcc (GCC) 11.0.0 20201204 (Red Hat 11.0.0-0)

* mmsghdr.c (struct mmsgvec_data): Change namelen[IOV_MAX] to an array
of zero length.

Change-Id: I0bea08bef0937582fbdda9ba7009a7b34251dbd1

mmsghdr.c

index 3fede19f7a7f8b2399bbe045a9b36690282c5b78..149f88b2f6764f7b128ab3f7aee3fda01f4badbc 100644 (file)
--- a/mmsghdr.c
+++ b/mmsghdr.c
@@ -71,7 +71,7 @@ free_mmsgvec_data(void *ptr)
 struct mmsgvec_data {
        char *timeout;
        unsigned int count;
-       int namelen[IOV_MAX];
+       int namelen[0];
 };
 
 static void