Bug 53984

Summary: /usr/include/bits/socket.h struct cmsghdr broken
Product: [Retired] Red Hat Linux Reporter: Brian Barrett <brbarret>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact: Aaron Brown <abrown>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: fweimer
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
URL: http://www.osl.iu.edu/~brbarret/redhat/
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-09-25 09:39:53 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Brian Barrett 2001-09-24 22:28:51 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.78 [en] (X11; U; SunOS 5.8 sun4u)

Description of problem:
On Red Hat 7.1, the struct cmsghdr defined in /usr/include/bits/socket.h is
broken when used with non-gcc compilers.  The size of the struct is
different on non-gcc compilers than on gcc compilers, so any code compiled
with non-gcc compilers and linked with the glibc rpm package will fail. 
This is true even if the CMSG_DATA macro is used.

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. Download the broken_cmsghdr.c from the URL above
2. Compile with gcc; run the exectuable.  Notice that it works.
3. Compile with something other than gcc (e.g., Portland Group compilers,
pgcc), and notice that it doesn't work.
4. Long comments in the sample .c file explain the problem.

Additional info:

The problem is actually in /usr/include/bits/socket.h, because a member in
the struct cmsghdr is not protected properly for non-gcc compilers.  Here's
a quick patch to fix  /usr/include/bits/socket.h (other linux distros do
this):

--- socket.h	Mon Sep 24 17:26:48 2001
+++ /usr/include/bits/socket.h	Mon Sep 24 15:42:27 2001
@@ -227,10 +227,8 @@
 				   of cmsghdr structure.  */
     int cmsg_level;		/* Originating protocol.  */
     int cmsg_type;		/* Protocol specific type.  */
-#if !defined __STRICT_ANSI__ && defined __GNUC__ && __GNUC__ >= 2
     __extension__ unsigned char __cmsg_data __flexarr; /* Ancillary data. 
*/
     /* XXX Perhaps this should be removed.  */
-#endif
   };
 
 /* Ancillary data object manipulation macros.  */

Comment 1 Jakub Jelinek 2001-09-25 09:39:48 UTC
Agreed, see http://sources.redhat.com/ml/libc-hacker/2001-09/msg00075.html

Comment 2 Jakub Jelinek 2001-10-17 16:00:20 UTC
Should be fixed in glibc-2.2.4-19.