On 03/09/2010 03:55 PM, Sven Joachim wrote:
On 2010-03-09 15:16 +0100, eric2.vale...@orange-ftgroup.com wrote:

Readding only the patch, the useage of the buffer returned by
get_current_dir_name may be wrong: the allocated space is by no way
equal to PATH_MAX+2 so any code making assumption on this may simply
fail.
There is no code which makes this assumption, but a slash is added to
the cwd string, so I need to allocate memory for it.  This is the bug
which I mentioned.
Then imagine next to the \0 is information used by malloc itself that you trash...
I would copy the result in the static buffer and free cwd.
That would be a possibility, although not the right thing on
architectures that do not have a PATH_MAX limit by themselves (e.g.,
Hurd).  But on those architectures symlinks is broken anyway.
pathconv(3) could be also used to avoid fixed PATH_MAX ;-)

--eric

Reply via email to