From 0fd43249a0c6d180a3a2ffc0ff850f6718592a6f Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 28 Feb 1999 13:01:23 +0000 Subject: 1999-02-28 Mark Kettenis * sysdeps/mach/hurd/getsockname.c (getsockname): Set *LEN to the actual length if the adress length is smaller than the input value. Change type of *LEN paramater to socklen_t. * sysdeps/mach/hurd/getpeername.c (getpeername): Likewise. * sysdeps/mach/hurd/accept.c (accept): Likewise. * sysdeps/mach/hurd/recvfrom.c (recvfrom): Likewise. * sysdeps/mach/hurd/sendto.c (sendto): Change type of ADDR_LEN paramater to socklen_t. --- sysdeps/mach/hurd/accept.c | 15 ++++++++------- sysdeps/mach/hurd/getpeername.c | 13 ++++++------- sysdeps/mach/hurd/getsockname.c | 11 ++++++----- sysdeps/mach/hurd/recvfrom.c | 13 ++++++------- sysdeps/mach/hurd/sendto.c | 8 ++++---- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/sysdeps/mach/hurd/accept.c b/sysdeps/mach/hurd/accept.c index 14e9848858..d0577dc398 100644 --- a/sysdeps/mach/hurd/accept.c +++ b/sysdeps/mach/hurd/accept.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992, 1993, 1994, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1992, 1993, 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,12 +17,12 @@ Boston, MA 02111-1307, USA. */ #include +#include +#include +#include #include #include -#include #include -#include -#include /* Await a connection on socket FD. When a connection arrives, open a new socket to communicate with it, @@ -33,7 +33,7 @@ int accept (fd, addrarg, addr_len) int fd; __SOCKADDR_ARG addrarg; - size_t *addr_len; + socklen_t *addr_len; { error_t err; socket_t new; @@ -69,10 +69,11 @@ accept (fd, addrarg, addr_len) if (addr != NULL) { + if (*addr_len > buflen) + *addr_len = buflen; + if (buf != (char *) addr) { - if (*addr_len < buflen) - *addr_len = buflen; memcpy (addr, buf, *addr_len); __vm_deallocate (__mach_task_self (), (vm_address_t) buf, buflen); } 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 +#include #include #include #include #include -#include /* 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); } diff --git a/sysdeps/mach/hurd/getsockname.c b/sysdeps/mach/hurd/getsockname.c index ad447eec79..9d049630e6 100644 --- a/sysdeps/mach/hurd/getsockname.c +++ b/sysdeps/mach/hurd/getsockname.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,18 +17,18 @@ Boston, MA 02111-1307, USA. */ #include +#include #include #include #include #include -#include /* Put the local address of FD into *ADDR and its length in *LEN. */ int getsockname (fd, addrarg, len) int fd; __SOCKADDR_ARG addrarg; - size_t *len; + socklen_t *len; { error_t err; struct sockaddr *addr = addrarg.__sockaddr__; @@ -46,10 +46,11 @@ getsockname (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); } diff --git a/sysdeps/mach/hurd/recvfrom.c b/sysdeps/mach/hurd/recvfrom.c index 981b922654..ab41612d71 100644 --- a/sysdeps/mach/hurd/recvfrom.c +++ b/sysdeps/mach/hurd/recvfrom.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1994, 1997 Free Software Foundation, Inc. +/* Copyright (C) 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,17 +17,15 @@ Boston, MA 02111-1307, USA. */ #include +#include #include #include #include #include -#include /* Read N bytes into BUF through socket FD from peer at address ADDR (which is ADDR_LEN bytes long). Returns the number read or -1 for errors. */ - -/* XXX should be __recvfrom ? */ int recvfrom (fd, buf, n, flags, addrarg, addr_len) int fd; @@ -35,7 +33,7 @@ recvfrom (fd, buf, n, flags, addrarg, addr_len) size_t n; int flags; __SOCKADDR_ARG addrarg; - size_t *addr_len; + socklen_t *addr_len; { error_t err; mach_port_t addrport; @@ -74,10 +72,11 @@ recvfrom (fd, buf, n, flags, addrarg, addr_len) if (err) return __hurd_dfail (fd, err); + if (*addr_len > buflen) + *addr_len = buflen; + if (buf != (char *) addr) { - if (*addr_len < buflen) - *addr_len = buflen; memcpy (addr, buf, *addr_len); __vm_deallocate (__mach_task_self (), (vm_address_t) buf, buflen); } diff --git a/sysdeps/mach/hurd/sendto.c b/sysdeps/mach/hurd/sendto.c index e59505e9f2..4f0ada7141 100644 --- a/sysdeps/mach/hurd/sendto.c +++ b/sysdeps/mach/hurd/sendto.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1994, 1995, 1996, 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 @@ -18,11 +18,11 @@ #include #include +#include #include -#include #include -#include #include +#include /* Send N bytes of BUF on socket FD to peer at address ADDR (which is ADDR_LEN bytes long). Returns the number sent, or -1 for errors. */ @@ -32,7 +32,7 @@ sendto (int fd, size_t n, int flags, const struct sockaddr_un *addr, - size_t addr_len) + socklen_t addr_len) { addr_port_t aport; error_t err; -- cgit 1.4.1