From: hno <> Date: Wed, 3 Oct 2001 15:16:13 +0000 (+0000) Subject: Don't rely on getcwd(NULL,..) allocating the needed memory. This is X-Git-Tag: SQUID_3_0_PRE1~1381 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4a504376407d2df4c74b6b478354a154e8fdd2c4;p=thirdparty%2Fsquid.git Don't rely on getcwd(NULL,..) allocating the needed memory. This is non-standardized and implementation dependent. --- diff --git a/src/main.cc b/src/main.cc index c43752e944..4785576881 100644 --- a/src/main.cc +++ b/src/main.cc @@ -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