This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/5070] New: glibc-2.5: ../sysdeps/unix/sysv/linux/check_pf.c:68: make_request: Assertion fails


When using getaddrinfo() in glibc-2.5 running on ARM9, I get the following:

../sysdeps/unix/sysv/linux/check_pf.c:68: make_request: Assertion `sizeof 
(req) - __builtin_offsetof (struct req, pad) == 3' failed.

The problem was introduced in Revision 1.7 
of "libc/sysdeps/unix/sysv/linux/check_pf.c". This works fine on x86 because of 
different alignment and packing rules required by the x86 architecture.

I suggest to do something like this instead:
--------------
 static int
 make_request (int fd, pid_t pid, bool *seen_ipv4, bool *seen_ipv6,
 	      struct in6addrinfo **in6ai, size_t *in6ailen)
 {
   struct req
   {
     struct nlmsghdr nlh;
     struct rtgenmsg g;
-    /* struct rtgenmsg consists of a single byte.  This means there
-       are three bytes of padding included in the REQ definition.
-       We make them explicit here.  */
-    char pad[3];
   } req;
   struct sockaddr_nl nladdr;
 
+  memset (&req, '\0', sizeof (req));
   req.nlh.nlmsg_len = sizeof (req);
   req.nlh.nlmsg_type = RTM_GETADDR;
   req.nlh.nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST;
   req.nlh.nlmsg_pid = 0;
   req.nlh.nlmsg_seq = time (NULL);
   req.g.rtgen_family = AF_UNSPEC;
 
-  assert (sizeof (req) - offsetof (struct req, pad) == 3);
-  memset (req.pad, '\0', sizeof (req.pad));
 
   memset (&nladdr, '\0', sizeof (nladdr));
   nladdr.nl_family = AF_NETLINK;
 
   if (TEMP_FAILURE_RETRY (__sendto (fd, (void *) &req, sizeof (req), 0,
 				    (struct sockaddr *) &nladdr,
 				    sizeof (nladdr))) < 0)
     return -1;
--------------

Regards

Tom Hunter

-- 
           Summary: glibc-2.5: ../sysdeps/unix/sysv/linux/check_pf.c:68:
                    make_request: Assertion fails
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: thunter at erggroup dot com
                CC: glibc-bugs at sources dot redhat dot com
 GCC build triplet: arm-9tdmi-linux-gnu
  GCC host triplet: arm-9tdmi-linux-gnu
GCC target triplet: arm-9tdmi-linux-gnu


http://sourceware.org/bugzilla/show_bug.cgi?id=5070

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]