Date: Sun, 12 Jan 1997 12:34:35 +0100 From: "Philippe Charnier" <charnier@xp11.frmug.org> To: davidn@blaze.net.au Cc: freebsd-bugs@freefall.freebsd.org Subject: Re: bin/2442: setusershell()/endusershell() missing Message-ID: <199701121134.MAA07158@xp11.frmug.org> In-Reply-To: Your message of "Thu, 11 Jan 1996 01:40:10 GMT." <Pine.BSF.3.95.960111012722.438A-100000@labs.usn.blaze.net.au>
next in thread | previous in thread | raw e-mail | index | archive | help
Salut,
David Nugent <davidn@unique.usn.blaze.net.au> wrote:
>
>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.
>
Most of the cases are safe imho, because 'sh' is tested against NULL
after endusershell() but never dereferenced. We can move enduser... 2 or 3
lines down to be purist.
The problem with my previous patch, is that it is simply incorrect (as you
mentionned) in /usr/bin/chpass, when 'sh' is returned (it's ok when 'name'
or NULL is returned) (ok_shell(), util.c).
>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.
>
I prefer the first (strdup() if I want to keep the result, then endusershell())
because I don't like waiting for exit() to free my memory.
Please add a line in the man page saying that a return value of getuser...
must not be dereferenced after enduser... is called.
------ ------
Philippe Charnier charnier@lirmm.fr (smtp)
charnier@xp11.frmug.org (uucp)
``a PC not running FreeBSD is like a venusian with no tentacles''
------------------------------------------------------------------------
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199701121134.MAA07158>
