From owner-freebsd-current Mon Dec 16 23:27:27 1996 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id XAA05756 for current-outgoing; Mon, 16 Dec 1996 23:27:27 -0800 (PST) Received: from tfs.com (tfs.com [140.145.250.1]) by freefall.freebsd.org (8.8.4/8.8.4) with SMTP id XAA05751 for ; Mon, 16 Dec 1996 23:27:26 -0800 (PST) Received: from critter.tfs.com by tfs.com (smail3.1.28.1) with SMTP id m0vZtvL-0003wLC; Mon, 16 Dec 96 23:26 PST Received: from critter.tfs.com (localhost.phk.dk [127.0.0.1]) by critter.tfs.com (8.8.2/8.8.2) with ESMTP id IAA14806; Tue, 17 Dec 1996 08:30:06 +0100 (MET) To: Bill Paul cc: current@freebsd.org Subject: Re: Plan for integrating Secure RPC -- comments wanted In-reply-to: Your message of "Tue, 17 Dec 1996 00:38:30 EST." <199612170538.AAA01464@skynet.ctr.columbia.edu> Date: Tue, 17 Dec 1996 08:30:05 +0100 Message-ID: <14804.850807805@critter.tfs.com> From: Poul-Henning Kamp Sender: owner-current@freebsd.org X-Loop: FreeBSD.org Precedence: bulk In message <199612170538.AAA01464@skynet.ctr.columbia.edu>, Bill Paul writes: > int optlen; > int optval; > int sock; > int rval; > > optlen = sizeof(optval); > rval = getsockopt(sock, SOL_SOCKET, SO_PEERUID, NULL, &optlen); > /* ^^^^ */ > /* deliberate bug: should be &optval */ > >According to the man page, getsockopt() should return EFAULT if optval >or optlen aren't within the process's address space. Well, NULL is not >within the process's address space, so I should get an error here, but >I don't. If I do something equally silly like use -1 instead of NULL, >then I get an EFAULT as expected. With NULL, the getsockopt() call doesn't >do anything, but it returns an rval of 0 and doesn't set errno. > >Looking at the getsockopt() code, it seems like it short-circuits the >uap->val (i.e. optval) == NULL case on purpose and doesn't return an >error. > >Am I nuts, or is this a bug? I belive the point is to return the length, so you can malloc sufficient storage and call again. -- Poul-Henning Kamp | phk@FreeBSD.ORG FreeBSD Core-team. http://www.freebsd.org/~phk | phk@login.dknet.dk Private mailbox. whois: [PHK] | phk@tfs.com TRW Financial Systems, Inc. Power and ignorance is a disgusting cocktail.