summary refs log tree commit diff
path: root/sysdeps/mach
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2005-10-23 00:46:40 +0000
committerRoland McGrath <roland@gnu.org>2005-10-23 00:46:40 +0000
commit2ba7a64cb93891e00729adff2a3f4674f1c23c78 (patch)
tree44070e6c0c327be35e4955aed0ff9e65757e44fd /sysdeps/mach
parentd8f5ccdde75ced2f5b7fe93dd9ef6ba58772b128 (diff)
downloadglibc-2ba7a64cb93891e00729adff2a3f4674f1c23c78.tar.gz
glibc-2ba7a64cb93891e00729adff2a3f4674f1c23c78.tar.xz
glibc-2ba7a64cb93891e00729adff2a3f4674f1c23c78.zip
2005-10-22  Roland McGrath  <roland@redhat.com>
	[BZ #1254]
	* sysdeps/mach/hurd/getpeername.c (__getpeername): Fix last change.
	From Samuel Thibault <samuel.thibault@ens-lyon.org>.
Diffstat (limited to 'sysdeps/mach')
-rw-r--r--sysdeps/mach/hurd/getpeername.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/sysdeps/mach/hurd/getpeername.c b/sysdeps/mach/hurd/getpeername.c
index 39071c1da4..325b6fd75d 100644
--- a/sysdeps/mach/hurd/getpeername.c
+++ b/sysdeps/mach/hurd/getpeername.c
@@ -55,11 +55,14 @@ __getpeername (int fd, __SOCKADDR_ARG addrarg, socklen_t *len)
     }
 
   const sa_family_t family = type;
-  if (*len < (char *) (&addr->sa_family + 1) - (char *) addr)
-    memcpy (&addr->sa_family, &family,
-	    *len - offsetof (struct sockaddr, sa_family));
-  else
-    addr->sa_family = family;
+  if (*len > offsetof (struct sockaddr, sa_family))
+    {
+      if (*len < (char *) (&addr->sa_family + 1) - (char *) addr)
+	memcpy (&addr->sa_family, &family,
+		*len - offsetof (struct sockaddr, sa_family));
+      else
+	addr->sa_family = family;
+    }
 
   return 0;
 }