From owner-freebsd-bugs Sat Jan 11 06:41:33 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id GAA19318 for bugs-outgoing; Sat, 11 Jan 1997 06:41:33 -0800 (PST) Received: from labs.usn.blaze.net.au (labs.usn.blaze.net.au [203.17.53.30]) by freefall.freebsd.org (8.8.4/8.8.4) with ESMTP id GAA19293; Sat, 11 Jan 1997 06:40:30 -0800 (PST) Received: from localhost (davidn@localhost) by labs.usn.blaze.net.au (8.8.4/8.8.4) with SMTP id MAA00541; Thu, 11 Jan 1996 12:40:11 +1100 (EST) Date: Thu, 11 Jan 1996 01:40:10 +0000 () From: David Nugent Reply-To: davidn@blaze.net.au To: Philippe Charnier cc: FreeBSD-gnats-submit@freebsd.org, GNATS Management , freebsd-bugs@freefall.freebsd.org Subject: Re: bin/2442: setusershell()/endusershell() missing In-Reply-To: <199701110134.CAA28437@xp11.frmug.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-bugs@freebsd.org X-Loop: FreeBSD.org Precedence: bulk On Sat, 11 Jan 1997, Philippe Charnier wrote: > The right way (TM) should be: > setusershell() > some getusershell() > endusershell() In theory at least. :-) > setusershell(); > while (sh = getusershell()) { > if (!strcmp(name, sh)) >- return (name); >+ { endusershell(); return (name); } > /* allow just shell name, but use "real" path */ > if ((p = strrchr(sh, '/')) && strcmp(name, p + 1) == 0) >- return (sh); >+ { endusershell(); return (sh); } The problem in some places patched is that 'sh' will point to memory that has been free()'ed by the call to endusershell(). Not all, but some. Either this should be documented, and strdup() called prior endusershell() is called and the strdup()ed copy should be returned, or /usr/src/lib/libc/gen/getusershell.c should be made to not to free that memory, but recycle it should setusershell() be called again. I think the latter is a better solution, which would allow this patch to work as is. However, libc needs to be fixed first. Regards, David Nugent - Unique Computing Pty Ltd - Melbourne, Australia Voice +61-3-9791-9547 Data/BBS +61-3-9792-3507 3:632/348@fidonet davidn@freebsd.org davidn@blaze.net.au http://www.blaze.net.au/~davidn/