2001-06-06 Roland McGrath <roland@frob.com>
* sysdeps/mach/hurd/getsockopt.c: Fix handling of returned buffer size. From Robert Bihlmeyer <robbe@orcus.priv.at>.
This commit is contained in:
parent
eb12749a92
commit
d652f6b8cb
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 1992, 1994, 1997 Free Software Foundation, Inc.
|
/* Copyright (C) 1992,94,97,2001 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
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)))
|
&buf, &buflen)))
|
||||||
return __hurd_dfail (fd, err);
|
return __hurd_dfail (fd, err);
|
||||||
|
|
||||||
|
if (*optlen > buflen)
|
||||||
|
*optlen = buflen;
|
||||||
if (buf != optval)
|
if (buf != optval)
|
||||||
{
|
{
|
||||||
if (*optlen < buflen)
|
|
||||||
*optlen = buflen;
|
|
||||||
memcpy (optval, buf, *optlen);
|
memcpy (optval, buf, *optlen);
|
||||||
__vm_deallocate (__mach_task_self (), (vm_address_t) buf, buflen);
|
__vm_deallocate (__mach_task_self (), (vm_address_t) buf, buflen);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue