From 999b49c49ca8ee4adb78c6feb8b9d5932f463714 Mon Sep 17 00:00:00 2001 From: oes Date: Thu, 3 Apr 2003 15:08:42 +0000 Subject: [PATCH] No longer rely on non-POSIX.1 extensions of getcwd(). Fixes bug #711001 --- jcc.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/jcc.c b/jcc.c index 6f120ea9..d7496973 100644 --- a/jcc.c +++ b/jcc.c @@ -1,4 +1,4 @@ -const char jcc_rcs[] = "$Id: jcc.c,v 1.92.2.7 2003/03/17 16:48:59 oes Exp $"; +const char jcc_rcs[] = "$Id: jcc.c,v 1.92.2.8 2003/03/31 13:12:32 oes Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/Attic/jcc.c,v $ @@ -33,6 +33,10 @@ const char jcc_rcs[] = "$Id: jcc.c,v 1.92.2.7 2003/03/17 16:48:59 oes Exp $"; * * Revisions : * $Log: jcc.c,v $ + * Revision 1.92.2.8 2003/03/31 13:12:32 oes + * Replaced setenv() by posix-compliant putenv() + * Thanks to Neil McCalden (nmcc AT users.sf.net). + * * Revision 1.92.2.7 2003/03/17 16:48:59 oes * Added chroot ability, thanks to patch by Sviatoslav Sviridov * @@ -1852,16 +1856,17 @@ int main(int argc, const char *argv[]) #if defined(unix) if ( *configfile != '/' ) { - char *abs_file; + char *abs_file, cwd[1024]; /* make config-filename absolute here */ - if ( !(basedir = getcwd( NULL, 1024 ))) + if ( !(getcwd(cwd, sizeof(cwd)))) { perror("get working dir failed"); exit( 1 ); } - if ( !(abs_file = malloc( strlen( basedir ) + strlen( configfile ) + 5 ))) + if (!(basedir = strdup(cwd)) + || (!(abs_file = malloc( strlen( basedir ) + strlen( configfile ) + 5 )))) { perror("malloc failed"); exit( 1 ); -- 2.49.0