From 9898afa1f14253d2fe861c4f6fb75fcbb012c3d3 Mon Sep 17 00:00:00 2001 From: Garrett Wollman Date: Mon, 31 Aug 1998 18:07:23 +0000 Subject: [PATCH] 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. --- sys/kern/uipc_socket.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index defd2a8744e..05d312f6530 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -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 @@ -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);