diff options
Diffstat (limited to 'sysdeps/mach/hurd/getpeername.c')
-rw-r--r-- | sysdeps/mach/hurd/getpeername.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/sysdeps/mach/hurd/getpeername.c b/sysdeps/mach/hurd/getpeername.c index 54e92795d1..ffb05d551a 100644 --- a/sysdeps/mach/hurd/getpeername.c +++ b/sysdeps/mach/hurd/getpeername.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992, 1994, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1992, 1994, 1997, 1999 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 @@ -17,21 +17,19 @@ Boston, MA 02111-1307, USA. */ #include <errno.h> +#include <string.h> #include <sys/socket.h> #include <hurd.h> #include <hurd/fd.h> #include <hurd/socket.h> -#include <string.h> /* Put the address of the peer connected to socket FD into *ADDR (which is *LEN bytes long), and its actual length into *LEN. */ - -/* XXX should be __getpeername ? */ int getpeername (fd, addrarg, len) int fd; __SOCKADDR_ARG addrarg; - size_t *len; + socklen_t *len; { error_t err; mach_msg_type_number_t buflen = *len; @@ -49,10 +47,11 @@ getpeername (fd, addrarg, len) if (err) return __hurd_dfail (fd, err); + if (*len > buflen) + *len = buflen; + if (buf != (char *) addr) { - if (*len < buflen) - *len = buflen; memcpy (addr, buf, *len); __vm_deallocate (__mach_task_self (), (vm_address_t) buf, buflen); } |