patch: current dir segfault

From: Andres Kroonmaa <andre@dont-contact.us>
Date: Wed, 3 Oct 2001 00:17:09 +0200

 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 Tue Oct 02 2001 - 16:24:20 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:14:23 MST