From owner-freebsd-commit Tue Nov 14 02:03:18 1995 Return-Path: owner-commit Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id CAA21046 for freebsd-commit-outgoing; Tue, 14 Nov 1995 02:03:18 -0800 Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id CAA21016 for cvs-all-outgoing; Tue, 14 Nov 1995 02:03:11 -0800 Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id CAA20983 for cvs-sys-outgoing; Tue, 14 Nov 1995 02:03:03 -0800 Received: from tfs.com (tfs.com [140.145.250.1]) by freefall.freebsd.org (8.6.12/8.6.6) with SMTP id CAA20905 ; Tue, 14 Nov 1995 02:02:27 -0800 Received: from critter.tfs.com by tfs.com (smail3.1.28.1) with SMTP id m0tFIBm-0003vyC; Tue, 14 Nov 95 02:02 PST Received: from localhost (localhost [127.0.0.1]) by critter.tfs.com (8.6.11/8.6.9) with SMTP id LAA00572; Tue, 14 Nov 1995 11:01:48 +0100 X-Authentication-Warning: localhost.tfs.com: Host localhost didn't use HELO protocol To: Peter Wemm cc: Poul-Henning Kamp , CVS-commiters@freefall.freebsd.org, cvs-sys@freefall.freebsd.org Subject: Re: cvs commit: src/sys/kern kern_sysctl.c In-reply-to: Your message of "Tue, 14 Nov 1995 04:48:24 +0800." Date: Tue, 14 Nov 1995 11:01:48 +0100 Message-ID: <570.816343308@critter.tfs.com> From: Poul-Henning Kamp Sender: owner-commit@FreeBSD.org Precedence: bulk > Yep. You missed this one: Well, maybe... > + #if 0 > if (arg2) > error = SYSCTL_OUT(req, arg1, arg2); > else > + #endif > This is necessary for sysctl_handle_string (a string by definition is > null terminated. use the sysctl_handle_opaque for a fixed block of > memory. the hostname buffer is a string, not a 256 byte chunk) > > If you dont do the above change, gethostname(buf, 64) will fail with > ENOMEM, and cause gated, amd and mountd to fail. Well, what if the hostname actually WAS 255 bytes long then ? I would rather it fail all the time and we can get the code fixed, than having a mismatch between expectations like this... > I've been using the following hack regression check program while > fiddling. It's probably not entirely right, but it demonstrates the > results of the above breakage. got it. > BTW: it seems like the old sysctl() does not behave as documented.. It > doesn't seem like it will return an estimate of the KERN_HOSTNAME size on > a very old 2.2-current (27 september). The manpage explicitly says > "returns 0 on success and -1 on failure". Old -current and -stable may > need the first assert() commented out. The interface is badly designed, how about this one: get some variable old buffer too small, new buffer correct. it should return ENOMEM because it cannot copyout, but should the new value be installed ? I'm seriously considering allowing only a "get" or a "set" per syscall, not both. But then again, that is too draconian isn't it ? -- Poul-Henning Kamp | phk@FreeBSD.ORG FreeBSD Core-team. http://www.freebsd.org/~phk | phk@login.dknet.dk Private mailbox. whois: [PHK] | phk@ref.tfs.com TRW Financial Systems, Inc. Future will arrive by its own means, progress not so.