On Thu, 2007-12-20 at 12:30 +0100, Andreas Schwab wrote: > Michael Haubenwallner <[EMAIL PROTECTED]> writes: > > > diff -ru builtins/common.c builtins/common.c > > --- builtins/common.c Wed Dec 19 10:30:07 2007 > > +++ builtins/common.c Wed Dec 19 10:34:58 2007 > > @@ -479,11 +479,8 @@ > > > > if (the_current_working_directory == 0) > > { > > -#if defined (GETCWD_BROKEN) > > - the_current_working_directory = getcwd (0, PATH_MAX); > > -#else > > - the_current_working_directory = getcwd (0, 0); > > -#endif > > + char *t = xmalloc(PATH_MAX); > > + the_current_working_directory = getcwd (t, PATH_MAX); > > The length of the cwd may be bigger than PATH_MAX.
Eventually - but there are three (ok, two) other locations in bash-3.2 where buffer[PATH_MAX] is passed to getcwd(): 1) jobs.c: current_working_directory() 2) parse.y: decode_prompt_string() 3) lib/readline/examples/fileman.c: com_pwd() ok, this just is an example, and uses 1024 instead of PATH_MAX. Instead of using PATH_MAX, why not have some xgetcwd() instead, doing malloc (when getcwd does not allocate itself), and increase the buffer when getcwd() returns ERANGE ? /haubi/ -- Michael Haubenwallner Gentoo on a different level