[Glibc-bsd-commits] r3739 - in trunk/glibc-ports/kfreebsd: . socket socket/sys sys

Petr Salinger ps-guest at alioth.debian.org
Mon Oct 17 13:03:21 UTC 2011


Author: ps-guest
Date: 2011-10-17 13:03:21 +0000 (Mon, 17 Oct 2011)
New Revision: 3739

Added:
   trunk/glibc-ports/kfreebsd/socket/
   trunk/glibc-ports/kfreebsd/socket/sys/
   trunk/glibc-ports/kfreebsd/socket/sys/un.h
   trunk/glibc-ports/kfreebsd/sys/un.h
Modified:
   trunk/glibc-ports/kfreebsd/bind.c
   trunk/glibc-ports/kfreebsd/connect.c
   trunk/glibc-ports/kfreebsd/sa_len.c
   trunk/glibc-ports/kfreebsd/sendto.c
Log:
FreeBSD's kernel have different sun_path length compared to linux


Modified: trunk/glibc-ports/kfreebsd/bind.c
===================================================================
--- trunk/glibc-ports/kfreebsd/bind.c	2011-10-16 11:30:35 UTC (rev 3738)
+++ trunk/glibc-ports/kfreebsd/bind.c	2011-10-17 13:03:21 UTC (rev 3739)
@@ -50,7 +50,7 @@
 
   /* Only allow a smaller size, otherwise it could lead to
     stack corruption */
-  if (new_addrlen < addrlen)
+  if ((new_addrlen != 0) && (new_addrlen < addrlen))
     addrlen = new_addrlen;
 
   /* We pass 3 arguments.  */

Modified: trunk/glibc-ports/kfreebsd/connect.c
===================================================================
--- trunk/glibc-ports/kfreebsd/connect.c	2011-10-16 11:30:35 UTC (rev 3738)
+++ trunk/glibc-ports/kfreebsd/connect.c	2011-10-17 13:03:21 UTC (rev 3739)
@@ -51,7 +51,7 @@
 
   /* Only allow a smaller size, otherwise it could lead to
     stack corruption */
-  if (new_addrlen < addrlen)
+  if ((new_addrlen != 0) && (new_addrlen < addrlen))
     addrlen = new_addrlen;
 
   /* We pass 3 arguments.  */

Modified: trunk/glibc-ports/kfreebsd/sa_len.c
===================================================================
--- trunk/glibc-ports/kfreebsd/sa_len.c	2011-10-16 11:30:35 UTC (rev 3738)
+++ trunk/glibc-ports/kfreebsd/sa_len.c	2011-10-17 13:03:21 UTC (rev 3739)
@@ -37,7 +37,7 @@
     case AF_IPX:
       return sizeof (struct sockaddr_ipx);
     case AF_LOCAL:
-      return sizeof (struct sockaddr_un);
+      return sizeof (struct sockaddr_un) - sizeof(((struct sockaddr_un *) 0)->__sun_user_compat);
     }
   return 0;
 }

Modified: trunk/glibc-ports/kfreebsd/sendto.c
===================================================================
--- trunk/glibc-ports/kfreebsd/sendto.c	2011-10-16 11:30:35 UTC (rev 3738)
+++ trunk/glibc-ports/kfreebsd/sendto.c	2011-10-17 13:03:21 UTC (rev 3739)
@@ -55,7 +55,7 @@
 
   /* Only allow a smaller size, otherwise it could lead to
     stack corruption */
-  if (new_addrlen < addrlen)
+  if ((new_addrlen != 0) && (new_addrlen < addrlen))
     addrlen = new_addrlen;
   }
 

Added: trunk/glibc-ports/kfreebsd/socket/sys/un.h
===================================================================
--- trunk/glibc-ports/kfreebsd/socket/sys/un.h	                        (rev 0)
+++ trunk/glibc-ports/kfreebsd/socket/sys/un.h	2011-10-17 13:03:21 UTC (rev 3739)
@@ -0,0 +1,2 @@
+/* kludge to satisfy $SRC/include/sys/un.h */
+#include <kfreebsd/sys/un.h>

Added: trunk/glibc-ports/kfreebsd/sys/un.h
===================================================================
--- trunk/glibc-ports/kfreebsd/sys/un.h	                        (rev 0)
+++ trunk/glibc-ports/kfreebsd/sys/un.h	2011-10-17 13:03:21 UTC (rev 3739)
@@ -0,0 +1,48 @@
+/* Copyright (C) 1991, 1995, 1996, 2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef	_SYS_UN_H
+#define	_SYS_UN_H	1
+
+#include <sys/cdefs.h>
+
+/* Get the definition of the macro to define the common sockaddr members.  */
+#include <bits/sockaddr.h>
+
+__BEGIN_DECLS
+
+/* Structure describing the address of an AF_LOCAL (aka AF_UNIX) socket.  */
+struct sockaddr_un
+  {
+    __SOCKADDR_COMMON (sun_);
+    char sun_path[104];		/* Path name, the kernel restrict it to 104, */
+    char __sun_user_compat[4];  /* but former user header used 108 */
+  };
+
+
+#ifdef __USE_MISC
+# include <string.h>		/* For prototype of `strlen'.  */
+
+/* Evaluate to actual length of the `sockaddr_un' structure.  */
+# define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path)	      \
+		      + strlen ((ptr)->sun_path))
+#endif
+
+__END_DECLS
+
+#endif	/* sys/un.h  */




More information about the Glibc-bsd-commits mailing list