]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Don't rely on getcwd(NULL,..) allocating the needed memory. This is
authorhno <>
Wed, 3 Oct 2001 15:16:13 +0000 (15:16 +0000)
committerhno <>
Wed, 3 Oct 2001 15:16:13 +0000 (15:16 +0000)
non-standardized and implementation dependent.

src/main.cc

index c43752e944fc6de5a3d404d1112d67896ab9dd15..4785576881b5c868173e67bc8a59d4b2ac51ede5 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: main.cc,v 1.341 2001/09/03 23:01:45 wessels Exp $
+ * $Id: main.cc,v 1.342 2001/10/03 09:16:13 hno Exp $
  *
  * DEBUG: section 1     Startup and Main Loop
  * AUTHOR: Harvest Derived
@@ -422,7 +422,7 @@ setEffectiveUser(void)
 static void
 mainSetCwd(void)
 {
-    char *p;
+    char pathbuf[MAXPATHLEN];
     if (Config.coredump_dir) {
        if (0 == strcmp("none", Config.coredump_dir)) {
            (void) 0;
@@ -434,9 +434,11 @@ mainSetCwd(void)
        }
     }
     /* 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);
+    if (getcwd(pathbuf, MAXPATHLEN)) {
+       debug(0, 1) ("Current Directory is %s\n", pathbuf);
+    } else {
+       debug(50, 0) ("WARNING: Can't find current directory, getcwd: %s\n", xstrerror());
+    }
 }
 
 static void