From owner-freebsd-hackers Tue Nov 14 10:39:41 1995 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id KAA01167 for hackers-outgoing; Tue, 14 Nov 1995 10:39:41 -0800 Received: from haywire.DIALix.COM (news@haywire.DIALix.COM [192.203.228.65]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id KAA01150 for ; Tue, 14 Nov 1995 10:39:30 -0800 Received: (from news@localhost) by haywire.DIALix.COM (sendmail) id CAA08895 for freebsd-hackers@freebsd.org; Wed, 15 Nov 1995 02:38:41 +0800 (WST) Received: from GATEWAY by haywire.DIALix.COM with netnews for freebsd-hackers@freebsd.org (problems to: usenet@haywire.dialix.com) To: freebsd-hackers@freebsd.org Date: 15 Nov 1995 02:38:36 +0800 From: peter@haywire.dialix.com (Peter Wemm) Message-ID: <48annc$8lr$1@haywire.DIALix.COM> Organization: DIALix Services, Perth, Australia. References: <199511141418.PAA03522@allegro.lemis.de>, <1053.816359324@critter.tfs.com> Subject: Re: Can't NFS mount with latest -current Sender: owner-hackers@freebsd.org Precedence: bulk phk@critter.tfs.com (Poul-Henning Kamp) writes: >> I've traced this back to /usr/src/kern/kern_sysctl.c, but haven't got >> round to finding out why it dies (it's difficult without an editor and >> a debugger :-) It looks as if you've seen problems in this area >> before, though. >A lot of commits went into kern_sysctl.c lately. The most recent of these >are belived to be mostly correct even. There may still be an issue >if the program doesn't allocate a sufficiently large buffer for things >like the hostname (256 chars) I think, which this could look like it is. What if you have a binary that was compiled on a system with MAXHOSTNAMELEN=64 (as is the traitional BSD value), and you do not have source? IMO, gethostname(buf, 64) should not fail unless the hostname is longer than 64 characters! What's worse, is that older software was written with the knowledge that "MAXHOSTNAMELEN" is not portable across systems and use their own non-conflicting constant. On some systems, the #define is in rather than in . On other systems, the actual maximum hostname length is _SYS_NMLEN(256) while the token MAXHOSTNAMELEN is a bogus "64" despite the fact that gethostname() on those systems will return up to 256 characters. For the people out there who are stuck while this is being resolved, you might want to try this patch to -current.. Index: kern_sysctl.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_sysctl.c,v retrieving revision 1.49 diff -c -r1.49 kern_sysctl.c *** kern_sysctl.c 1995/11/14 09:42:22 1.49 --- kern_sysctl.c 1995/11/14 15:59:14 *************** *** 293,301 **** --- 293,303 ---- { int error=0; + #if 0 /* Broken! this breaks traditional gethostname(buf, 64) */ if (arg2) error = SYSCTL_OUT(req, arg1, arg2); else + #endif error = SYSCTL_OUT(req, arg1, strlen((char *)arg1)+1); if (error || !req->newptr || !arg2) (Damn.. I've had another go at Poul-Henning.. He must be cursing me by now.. Sorry again... :-) Anyway, Poul-Henning has created two sysctl types.. one is a null-terminated "C-style" string, and the other is an "opaque" chunk of byte counted memory. IMHO, the string version should always return the correct amount of characters that the string actually uses. If the whole block is to be returned, that's what the opaque type is for. -Peter >-- >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.