Date: Sat, 11 Jan 1997 06:50:01 -0800 (PST) From: David Nugent <davidn@unique.usn.blaze.net.au> To: freebsd-bugs Subject: Re: bin/2442: setusershell()/endusershell() missing Message-ID: <199701111450.GAA19520@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/2442; it has been noted by GNATS. 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 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/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199701111450.GAA19520>