Date: Thu, 11 Jan 1996 01:40:10 +0000 () From: David Nugent <davidn@unique.usn.blaze.net.au> To: Philippe Charnier <charnier@xp11.frmug.org> Cc: FreeBSD-gnats-submit@freebsd.org, GNATS Management <gnats@freefall.freebsd.org>, freebsd-bugs@freefall.freebsd.org Subject: Re: bin/2442: setusershell()/endusershell() missing Message-ID: <Pine.BSF.3.95.960111012722.438A-100000@labs.usn.blaze.net.au> In-Reply-To: <199701110134.CAA28437@xp11.frmug.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.95.960111012722.438A-100000>