git-CMSG_DATA
authorGNU Libc Maintainers <debian-glibc@lists.debian.org>
Sat, 15 Feb 2025 10:20:09 +0000 (11:20 +0100)
committerAurelien Jarno <aurel32@debian.org>
Sat, 15 Feb 2025 10:20:09 +0000 (11:20 +0100)
commit cf13f740a91b5bbf6bb60a30b45c2a3933ff1259
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date:   Wed Jan 1 22:07:42 2025 +0100

    bits/socket.h: Update to recent BSD definition

    The old BSD 4.4 definition (not used by Linux) was not 64b-proof: the
    cmsg_data field is supposed to CMSG_ALIGN'ed (as can be also seen in the
    CMSG_LEN macro).

Suggested-by: Diego Nieto Cid <dnietoc@gmail.com>
Gbp-Pq: Topic hurd-i386
Gbp-Pq: Name git-CMSG_DATA.diff

bits/socket.h
sysdeps/mach/hurd/bits/socket.h

index 772074d52ab957dfa40ff9921d9d07b35aa41fd5..5293e0fa12b0082fc23b8f750e0a3c517d223617 100644 (file)
@@ -221,17 +221,13 @@ struct cmsghdr
                                   of cmsghdr structure.  */
     int cmsg_level;            /* Originating protocol.  */
     int cmsg_type;             /* Protocol specific type.  */
-#if __glibc_c99_flexarr_available
-    __extension__ unsigned char __cmsg_data __flexarr; /* Ancillary data.  */
-#endif
+ /* This field is to be aligned with CMSG_ALIGN */
+ /* __extension__ unsigned char __cmsg_data __flexarr; */ /* Ancillary data.  */
   };
 
 /* Ancillary data object manipulation macros.  */
-#if __glibc_c99_flexarr_available
-# define CMSG_DATA(cmsg) ((cmsg)->__cmsg_data)
-#else
-# define CMSG_DATA(cmsg) ((unsigned char *) ((struct cmsghdr *) (cmsg) + 1))
-#endif
+#define CMSG_DATA(cmsg) \
+  ((unsigned char *) (cmsg) + CMSG_ALIGN (sizeof (struct cmsghdr)))
 
 #define CMSG_NXTHDR(mhdr, cmsg) __cmsg_nxthdr (mhdr, cmsg)
 
index b5eeac373111e69473086806295fbe393b2ed4c2..cc043c8c5fd643f8bf9e66f1ed04e006f323f0ae 100644 (file)
@@ -228,17 +228,13 @@ struct cmsghdr
                                   of cmsghdr structure.  */
     int cmsg_level;            /* Originating protocol.  */
     int cmsg_type;             /* Protocol specific type.  */
-#if __glibc_c99_flexarr_available
-    __extension__ unsigned char __cmsg_data __flexarr; /* Ancillary data.  */
-#endif
+ /* This field is to be aligned with CMSG_ALIGN */
+ /* __extension__ unsigned char __cmsg_data __flexarr; */ /* Ancillary data.  */
   };
 
 /* Ancillary data object manipulation macros.  */
-#if __glibc_c99_flexarr_available
-# define CMSG_DATA(cmsg) ((cmsg)->__cmsg_data)
-#else
-# define CMSG_DATA(cmsg) ((unsigned char *) ((struct cmsghdr *) (cmsg) + 1))
-#endif
+#define CMSG_DATA(cmsg) \
+  ((unsigned char *) (cmsg) + CMSG_ALIGN (sizeof (struct cmsghdr)))
 
 #define CMSG_NXTHDR(mhdr, cmsg) __cmsg_nxthdr (mhdr, cmsg)