cvs: php4 /main fopen_wrappers.c

From: Date: Sun, 15 Jul 2001 12:24:06 +0000
Subject: cvs: php4 /main fopen_wrappers.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-6230@lists.php.net to get a copy of this message
zeev Sun Jul 15 08:24:06 2001 EDT Modified files: /php4/main fopen_wrappers.c Log: Fix a crash with the new check-in-cwd code. It will now work only with files which are included in runtime, and not files which are opened at startup (e.g., php.ini) Index: php4/main/fopen_wrappers.c diff -u php4/main/fopen_wrappers.c:1.122 php4/main/fopen_wrappers.c:1.123 --- php4/main/fopen_wrappers.c:1.122 Fri Jul 13 14:21:21 2001 +++ php4/main/fopen_wrappers.c Sun Jul 15 08:24:06 2001 @@ -16,7 +16,7 @@ | Jim Winstead <jimw@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: fopen_wrappers.c,v 1.122 2001/07/13 18:21:21 jflemer Exp $ */ +/* $Id: fopen_wrappers.c,v 1.123 2001/07/15 12:24:06 zeev Exp $ */ /* {{{ includes */ @@ -464,26 +464,30 @@ /* append the calling scripts' current working directory * as a fall back case */ - exec_fname = zend_get_executed_filename(ELS_C); - exec_fname_length = strlen(exec_fname); - path_length = strlen(path); - - while ((--exec_fname_length >= 0) && !IS_SLASH(exec_fname[exec_fname_length])) { - } - if (exec_fname && exec_fname[0] == '[') { - /* [no active file] */ - exec_fname_length = 0; - } - - pathbuf = (char *) emalloc(exec_fname_length + path_length +1 +1); - memcpy(pathbuf, path, path_length); + if (zend_is_executing()) { + exec_fname = zend_get_executed_filename(ELS_C); + exec_fname_length = strlen(exec_fname); + path_length = strlen(path); + + while ((--exec_fname_length >= 0) && !IS_SLASH(exec_fname[exec_fname_length])) { + } + if (exec_fname && exec_fname[0] == '[') { + /* [no active file] */ + exec_fname_length = 0; + } + + pathbuf = (char *) emalloc(exec_fname_length + path_length +1 +1); + memcpy(pathbuf, path, path_length); #ifdef PHP_WIN32 - pathbuf[path_length] = ';'; + pathbuf[path_length] = ';'; #else - pathbuf[path_length] = ':'; + pathbuf[path_length] = ':'; #endif - memcpy(pathbuf+path_length+1, exec_fname, exec_fname_length); - pathbuf[path_length + exec_fname_length +1] = '\0'; + memcpy(pathbuf+path_length+1, exec_fname, exec_fname_length); + pathbuf[path_length + exec_fname_length +1] = '\0'; + } else { + pathbuf = estrdup(path); + } ptr = pathbuf;

« previous php.cvs (#6230) next »