From e0d788ef18f2fa8ee9afd7872e25456148f024d0 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 3 Feb 2000 01:21:32 +0000 Subject: [PATCH] 2000-02-02 Roland McGrath * sysdeps/mach/hurd/getsockopt.c (getsockopt): Fix inverted sense of test: *OPTLEN gets BUFLEN iff BUFLEN is lesser. Move that test out of BUF != OPTVAL condition, since it is a separate issue. Short-circuit the memcpy and dealloc for BUFLEN==0. --- sysdeps/mach/hurd/getsockopt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sysdeps/mach/hurd/getsockopt.c b/sysdeps/mach/hurd/getsockopt.c index 36403543df9..87fb63aa6b4 100644 --- a/sysdeps/mach/hurd/getsockopt.c +++ b/sysdeps/mach/hurd/getsockopt.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992, 1994, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1992,94,97,2000 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 @@ -45,10 +45,10 @@ getsockopt (fd, level, optname, optval, optlen) &buf, &buflen))) return __hurd_dfail (fd, err); - if (buf != optval) + if (buflen < *optlen) + *optlen = buflen; + if (buflen != 0 && buf != optval) { - if (*optlen < buflen) - *optlen = buflen; memcpy (optval, buf, *optlen); __vm_deallocate (__mach_task_self (), (vm_address_t) buf, buflen); } -- 2.47.2