Date: 15 Nov 1995 02:38:36 +0800 From: peter@haywire.dialix.com (Peter Wemm) To: freebsd-hackers@freebsd.org Subject: Re: Can't NFS mount with latest -current Message-ID: <48annc$8lr$1@haywire.DIALix.COM> References: <199511141418.PAA03522@allegro.lemis.de>, <1053.816359324@critter.tfs.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <netdb.h> rather than in <sys/param.h>. 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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?48annc$8lr$1>