From owner-freebsd-bugs Sat Jan 11 06:50:03 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id GAA19540 for bugs-outgoing; Sat, 11 Jan 1997 06:50:03 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id GAA19520; Sat, 11 Jan 1997 06:50:01 -0800 (PST) Date: Sat, 11 Jan 1997 06:50:01 -0800 (PST) Message-Id: <199701111450.GAA19520@freefall.freebsd.org> To: freebsd-bugs Cc: From: David Nugent Subject: Re: bin/2442: setusershell()/endusershell() missing Reply-To: David Nugent Sender: owner-bugs@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk The following reply was made to PR bin/2442; it has been noted by GNATS. From: David Nugent To: Philippe Charnier Cc: FreeBSD-gnats-submit@freebsd.org, GNATS Management , freebsd-bugs@freefall.freebsd.org Subject: Re: bin/2442: setusershell()/endusershell() missing Date: Thu, 11 Jan 1996 01:40:10 +0000 () 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/