[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#645469: bind fails for AF_UNIX sockets with EINVAL



2011/10/17 Robert Millan <rmh@debian.org>:
> 2011/10/17 Petr Salinger <Petr.Salinger@seznam.cz>:
>> I just commited r3740 and r3739, at least one have to be active
>> with r3735 kernel.

Btw, could we restrict this kludge to platforms that need it?  See
attached patch.

-- 
Robert Millan
Index: sys/un.h
===================================================================
--- sys/un.h	(revision 3741)
+++ sys/un.h	(working copy)
@@ -31,7 +31,9 @@
   {
     __SOCKADDR_COMMON (sun_);
     char sun_path[104];		/* Path name, the kernel restrict it to 104, */
+#if defined(__i386__) || defined(__amd64__)
     char __sun_user_compat[4];  /* but former user header used 108 */
+#endif
   };
 
 
Index: sa_len.c
===================================================================
--- sa_len.c	(revision 3741)
+++ sa_len.c	(working copy)
@@ -22,6 +22,7 @@
 #include <netinet/in.h>
 #include <netipx/ipx.h>
 #include <sys/un.h>
+#include <stddef.h>
 
 int
 __libc_sa_len (sa_family_t af)
@@ -37,7 +38,7 @@
     case AF_IPX:
       return sizeof (struct sockaddr_ipx);
     case AF_LOCAL:
-      return sizeof (struct sockaddr_un) - sizeof(((struct sockaddr_un *) 0)->__sun_user_compat);
+      return offsetof (struct sockaddr_un, sun_path) + sizeof (((struct sockaddr_un *) 0)->sun_path);
     }
   return 0;
 }

Reply to: