This is what my getcwd manpage says:
As an extension to the POSIX.1 standard, getcwd() allo
cates the buffer dynamically using malloc() if buf is NULL
on call. In this case, the allocated buffer has the
length size unless size is zero, when buf is allocated as
big as necessary. It is possible (and, indeed, advisable)
to free() the buffers if they have been obtained this way.
and SUSv2 says
If buf is a null pointer, the behaviour of getcwd() is undefined.
So I think we better send a buffer there. Now done in HEAD. Please file
a bugzilla entry for fixing it in 2.4.
Patch:
http://www.squid-cache.org/cgi-bin/cvsweb.cgi/squid/src/main.c.diff?r1=1.341&r2=1.342
Regards
Henrik
Andres Kroonmaa wrote:
>
> if coredump_dir is not set in squid.conf, squid 2.4 segfaults.
> reason is misuse of getcwd() which expects size parameter.
> added check for cases getcwd returns error.
>
> ===================================================================
> --- main.c 2001/10/01 11:06:43 1.20.2.6
> +++ main.c 2001/10/02 22:15:19
> @@ -434,9 +434,13 @@
> }
> }
> /* If we don't have coredump_dir or couldn't cd there, report current dir */
> - p = getcwd(NULL, 0);
> - debug(0, 1) ("Current Directory is %s\n", p);
> - xfree(p);
> + p = getcwd(NULL, MAXPATHLEN);
> + if (p == NULL) {
> + debug(0, 1) ("Current Directory is %s\n", xstrerror());
> + } else {
> + debug(0, 1) ("Current Directory is %s\n", p);
> + xfree(p);
> + }
> }
>
> static void
>
> ------------------------------------
> Andres Kroonmaa <andre@online.ee>
> CTO, Microlink Online
> Tel: 6501 731, Fax: 6501 725
> Pärnu mnt. 158, Tallinn,
> 11317 Estonia
Received on Wed Oct 03 2001 - 04:14:30 MDT
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:14:23 MST