Bow to tradition and correctly implement the bogus-but-hallowed semantics
of getsockopt never telling how much it might have copied if only the buffer were big enough.
This commit is contained in:
parent
343eedd829
commit
bae4326618
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)uipc_socket.c 8.3 (Berkeley) 4/15/94
|
||||
* $Id: uipc_socket.c,v 1.43 1998/08/23 03:06:59 wollman Exp $
|
||||
* $Id: uipc_socket.c,v 1.44 1998/08/31 15:34:55 wollman Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -1078,13 +1078,14 @@ sooptcopyout(sopt, buf, len)
|
||||
/*
|
||||
* Documented get behavior is that we always return a value,
|
||||
* possibly truncated to fit in the user's buffer.
|
||||
* We leave the correct length in sopt->sopt_valsize,
|
||||
* to be copied out in getsockopt(). Note that this
|
||||
* interface is not idempotent; the entire answer must
|
||||
* Traditional behavior is that we always tell the user
|
||||
* precisely how much we copied, rather than something useful
|
||||
* like the total amount we had available for her.
|
||||
* Note that this interface is not idempotent; the entire answer must
|
||||
* generated ahead of time.
|
||||
*/
|
||||
valsize = min(len, sopt->sopt_valsize);
|
||||
sopt->sopt_valsize = len;
|
||||
sopt->sopt_valsize = valsize;
|
||||
if (sopt->sopt_val != 0) {
|
||||
if (sopt->sopt_p != 0)
|
||||
error = copyout(buf, sopt->sopt_val, valsize);
|
||||
|
Loading…
Reference in New Issue
Block a user