cvs: /php4 php.h php_virtual_cwd.c php_virtual_cwd.h /php4/dl/log log_db.c /php4/ext/db db.c /php4/ext/dba dba_db2.c dba_db3.c /php4/ext/session
mod_files.c session.c /php4/ext/standard filestat.c link.c /php4/ext/zlib zlib.c

From: Date: Thu, 20 Apr 2000 17:24:01 +0000
Subject: cvs: /php4 php.h php_virtual_cwd.c php_virtual_cwd.h /php4/dl/log log_db.c /php4/ext/db db.c /php4/ext/dba dba_db2.c dba_db3.c /php4/ext/session
mod_files.c session.c /php4/ext/standard filestat.c link.c /php4/ext/zlib zlib.c
Groups: php.version4 
Request: Send a blank email to php-version4+get-13812@lists.php.net to get a copy of this message
zeev Thu Apr 20 10:24:01 2000 EDT Modified files: /php4 php.h php_virtual_cwd.c php_virtual_cwd.h /php4/dl/log log_db.c /php4/ext/db db.c /php4/ext/dba dba_db2.c dba_db3.c /php4/ext/session mod_files.c session.c /php4/ext/standard filestat.c link.c /php4/ext/zlib zlib.c Log: - Fix virtual cwd bug - Add more V_STAT() V_LSTAT() changes Index: php4/php.h diff -u php4/php.h:1.83 php4/php.h:1.84 --- php4/php.h:1.83 Thu Apr 20 09:38:08 2000 +++ php4/php.h Thu Apr 20 10:23:59 2000 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php.h,v 1.83 2000/04/20 16:38:08 andi Exp $ */ +/* $Id: php.h,v 1.84 2000/04/20 17:23:59 zeev Exp $ */ #ifndef _PHP_H #define _PHP_H @@ -295,6 +295,7 @@ #define V_CHDIR_FILE(path) virtual_chdir_file(path) #define V_GETWD(buf) #define V_STAT(path, buff) virtual_stat(path, buff) +#define V_LSTAT(path, buff) virtual_lstat(path, buff) #else #define V_GETCWD(buff, size) getcwd(buff,size) #define V_FOPEN(path, mode) fopen(path, mode) @@ -302,6 +303,7 @@ #define V_CHDIR_FILE(path) chdir_file(path) #define V_GETWD(buf) getwd(buf) #define V_STAT(path, buff) stat(path, buff) +#define V_LSTAT(path, buff) lstat(path, buff) #endif #include "zend_constants.h" Index: php4/php_virtual_cwd.c diff -u php4/php_virtual_cwd.c:1.32 php4/php_virtual_cwd.c:1.33 --- php4/php_virtual_cwd.c:1.32 Thu Apr 20 09:38:08 2000 +++ php4/php_virtual_cwd.c Thu Apr 20 10:23:59 2000 @@ -7,9 +7,10 @@ #include <stdlib.h> #include <ctype.h> - #include "php_virtual_cwd.h" +#define VIRTUAL_CWD_DEBUG 0 + #ifdef ZTS #include "TSRM.h" #endif @@ -148,6 +149,9 @@ CWD_API void virtual_cwd_activate(char *filename) { +#if VIRTUAL_CWD_DEBUG + fprintf(stderr, "Changing dir to %s\n", filename); +#endif if (filename) { virtual_chdir_file(filename); } @@ -238,7 +242,9 @@ old_state = (cwd_state *) malloc(sizeof(cwd_state)); CWD_STATE_COPY(old_state, state); - +#if VIRTUAL_CWD_DEBUG + fprintf(stderr,"cwd = %s path = %s\n", state->cwd, path); +#endif if (IS_ABSOLUTE_PATH(path_copy, path_length)) { copy_amount = COPY_WHEN_ABSOLUTE; is_absolute = 1; @@ -310,7 +316,9 @@ free(old_state); efree(free_path); - +#if VIRTUAL_CWD_DEBUG + fprintf (stderr, "virtual_file_ex() = %s\n",state->cwd); +#endif return (ret); } @@ -324,6 +332,8 @@ CWD_API int virtual_chdir_file(char *path) { int length = strlen(path); + char *temp; + int retval; if (length == 0) { return 1; /* Can't cd to empty string */ @@ -334,8 +344,16 @@ if (length == -1) { return virtual_chdir(path); } - path[length] = DEFAULT_SLASH; - return virtual_chdir(path); + + temp = (char *) malloc(length+1); + memcpy(temp, path, length); + temp[length] = 0; +#if VIRTUAL_CWD_DEBUG + fprintf (stderr, "Changing directory to %s\n", temp); +#endif + retval = virtual_chdir(temp); + free(temp); + return retval; } @@ -378,6 +396,21 @@ virtual_file_ex(&new_state, path, NULL); retval = stat(new_state.cwd, buf); + CWD_STATE_FREE(&new_state); + return retval; +} + +CWD_API int virtual_lstat(const char *path, struct stat *buf) +{ + cwd_state new_state; + int retval; + CWDLS_FETCH(); + + CWD_STATE_COPY(&new_state, &CWDG(cwd)); + + virtual_file_ex(&new_state, path, NULL); + + retval = lstat(new_state.cwd, buf); CWD_STATE_FREE(&new_state); return retval; } Index: php4/php_virtual_cwd.h diff -u php4/php_virtual_cwd.h:1.13 php4/php_virtual_cwd.h:1.14 --- php4/php_virtual_cwd.h:1.13 Thu Apr 20 09:38:08 2000 +++ php4/php_virtual_cwd.h Thu Apr 20 10:23:59 2000 @@ -43,6 +43,7 @@ CWD_API int virtual_filepath(char *path, char **filepath); CWD_API FILE *virtual_fopen(const char *path, const char *mode); CWD_API int virtual_stat(const char *path, struct stat *buf); +CWD_API int virtual_lstat(const char *path, struct stat *buf); CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path); ZEND_BEGIN_MODULE_GLOBALS(cwd) Index: php4/dl/log/log_db.c diff -u php4/dl/log/log_db.c:1.4 php4/dl/log/log_db.c:1.5 --- php4/dl/log/log_db.c:1.4 Fri Dec 17 12:54:38 1999 +++ php4/dl/log/log_db.c Thu Apr 20 10:23:59 2000 @@ -27,7 +27,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: log_db.c,v 1.4 1999/12/17 20:54:38 zeev Exp $ */ +/* $Id: log_db.c,v 1.5 2000/04/20 17:23:59 zeev Exp $ */ #include "phpdl.h" #include "log.h" @@ -76,7 +76,7 @@ /* SAFE_MODE concern: should make sure that the user is logging somewhere safe */ - if (stat(log_conf.dbm_log_dir, &sb) == -1) { + if (V_STAT(log_conf.dbm_log_dir, &sb) == -1) { if (mkdir(log_conf.dbm_log_dir, 0755)==-1) { php_error(E_WARNING, "Trying to create main log directory [%s]: %d [%s]",log_conf.dbm_log_dir,errno,strerror(errno)); return; @@ -85,7 +85,7 @@ /* see if the log directory exists for this page-owner's uid */ sprintf(path, "%s/%ld", log_conf.dbm_log_dir, php_getuid()); - if (stat(path, &sb) == -1) { + if (V_STAT(path, &sb) == -1) { if (mkdir(path, 0755)==-1) { php_error(E_WARNING, "Trying to create user log directory [%s]: %d [%s]",path,errno,strerror(errno)); return; Index: php4/ext/db/db.c diff -u php4/ext/db/db.c:1.29 php4/ext/db/db.c:1.30 --- php4/ext/db/db.c:1.29 Sat Apr 15 07:19:59 2000 +++ php4/ext/db/db.c Thu Apr 20 10:23:59 2000 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: db.c,v 1.29 2000/04/15 14:19:59 andi Exp $ */ +/* $Id: db.c,v 1.30 2000/04/20 17:23:59 zeev Exp $ */ #define IS_EXT_MODULE #if COMPILE_DL # include "dl/phpdl.h" @@ -319,7 +319,7 @@ strcat(lockfn, ".lck"); #if NFS_HACK - while((last_try = stat(lockfn,&sb))==0) { + while((last_try = V_STAT(lockfn,&sb))==0) { retries++; php_sleep(1); if (retries>30) break; Index: php4/ext/dba/dba_db2.c diff -u php4/ext/dba/dba_db2.c:1.5 php4/ext/dba/dba_db2.c:1.6 --- php4/ext/dba/dba_db2.c:1.5 Wed Dec 29 22:09:46 1999 +++ php4/ext/dba/dba_db2.c Thu Apr 20 10:23:59 2000 @@ -27,7 +27,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: dba_db2.c,v 1.5 1999/12/30 06:09:46 sas Exp $ */ +/* $Id: dba_db2.c,v 1.6 2000/04/20 17:23:59 zeev Exp $ */ #include "php.h" @@ -61,7 +61,7 @@ type = info->mode == DBA_READER ? DB_UNKNOWN : info->mode == DBA_TRUNC ? DB_BTREE : - stat(info->path, &check_stat) ? DB_BTREE : DB_UNKNOWN; + V_STAT(info->path, &check_stat) ? DB_BTREE : DB_UNKNOWN; gmode = info->mode == DBA_READER ? DB_RDONLY : info->mode == DBA_CREAT ? DB_CREATE : Index: php4/ext/dba/dba_db3.c diff -u php4/ext/dba/dba_db3.c:1.3 php4/ext/dba/dba_db3.c:1.4 --- php4/ext/dba/dba_db3.c:1.3 Wed Dec 29 22:09:46 1999 +++ php4/ext/dba/dba_db3.c Thu Apr 20 10:23:59 2000 @@ -27,7 +27,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: dba_db3.c,v 1.3 1999/12/30 06:09:46 sas Exp $ */ +/* $Id: dba_db3.c,v 1.4 2000/04/20 17:23:59 zeev Exp $ */ #include "php.h" @@ -61,7 +61,7 @@ type = info->mode == DBA_READER ? DB_UNKNOWN : info->mode == DBA_TRUNC ? DB_BTREE : - stat(info->path, &check_stat) ? DB_BTREE : DB_UNKNOWN; + V_STAT(info->path, &check_stat) ? DB_BTREE : DB_UNKNOWN; gmode = info->mode == DBA_READER ? DB_RDONLY : info->mode == DBA_CREAT ? DB_CREATE : Index: php4/ext/session/mod_files.c diff -u php4/ext/session/mod_files.c:1.28 php4/ext/session/mod_files.c:1.29 --- php4/ext/session/mod_files.c:1.28 Wed Mar 29 12:37:12 2000 +++ php4/ext/session/mod_files.c Thu Apr 20 10:24:00 2000 @@ -175,7 +175,7 @@ snprintf(buf, MAXPATHLEN, "%s%c%s", dirname, DIR_DELIMITER, entry->d_name) > 0 && /* stat the directory entry */ - stat(buf, &sbuf) == 0 && + V_STAT(buf, &sbuf) == 0 && /* is it expired? */ (now - sbuf.st_atime) > maxlifetime) { unlink(buf); Index: php4/ext/session/session.c diff -u php4/ext/session/session.c:1.127 php4/ext/session/session.c:1.128 --- php4/ext/session/session.c:1.127 Thu Apr 6 14:07:43 2000 +++ php4/ext/session/session.c Thu Apr 20 10:24:00 2000 @@ -497,7 +497,7 @@ path = SG(request_info).path_translated; if (path) { - if (stat(path, &sb) == -1) { + if (V_STAT(path, &sb) == -1) { return; } Index: php4/ext/standard/filestat.c diff -u php4/ext/standard/filestat.c:1.31 php4/ext/standard/filestat.c:1.32 --- php4/ext/standard/filestat.c:1.31 Sat Apr 15 07:28:47 2000 +++ php4/ext/standard/filestat.c Thu Apr 20 10:24:00 2000 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: filestat.c,v 1.31 2000/04/15 14:28:47 andi Exp $ */ +/* $Id: filestat.c,v 1.32 2000/04/20 17:24:00 zeev Exp $ */ #include "php.h" #include "safe_mode.h" @@ -385,7 +385,7 @@ RETURN_FALSE; /* create the file if it doesn't exist already */ - ret = stat((*filename)->value.str.val, &sb); + ret = V_STAT((*filename)->value.str.val, &sb); if (ret == -1) { file = V_FOPEN((*filename)->value.str.val, "w"); if (file == NULL) { @@ -439,7 +439,7 @@ #if HAVE_SYMLINK BG(lsb).st_mode = 0; /* mark lstat buf invalid */ #endif - if (stat(BG(CurrentStatFile),&BG(sb))==-1) { + if (V_STAT(BG(CurrentStatFile),&BG(sb))==-1) { if (type != 15 || errno != ENOENT) { /* fileexists() test must print no error */ php_error(E_NOTICE,"stat failed for %s (errno=%d - %s)",BG(CurrentStatFile),errno,strerror(errno)); } @@ -457,7 +457,7 @@ /* do lstat if the buffer is empty */ if (!BG(lsb).st_mode) { - if (lstat(BG(CurrentStatFile),&BG(lsb)) == -1) { + if (V_LSTAT(BG(CurrentStatFile),&BG(lsb)) == -1) { php_error(E_NOTICE,"lstat failed for %s (errno=%d - %s)",BG(CurrentStatFile),errno,strerror(errno)); RETURN_FALSE; } Index: php4/ext/standard/link.c diff -u php4/ext/standard/link.c:1.19 php4/ext/standard/link.c:1.20 --- php4/ext/standard/link.c:1.19 Sat Feb 19 15:41:21 2000 +++ php4/ext/standard/link.c Thu Apr 20 10:24:00 2000 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: link.c,v 1.19 2000/02/19 23:41:21 zeev Exp $ */ +/* $Id: link.c,v 1.20 2000/04/20 17:24:00 zeev Exp $ */ #include "php.h" #include "php_filestat.h" @@ -88,7 +88,7 @@ } convert_to_string_ex(filename); - ret = lstat((*filename)->value.str.val, &sb); + ret = V_LSTAT((*filename)->value.str.val, &sb); if (ret == -1) { php_error(E_WARNING, "LinkInfo failed (%s)", strerror(errno)); RETURN_LONG(-1L); Index: php4/ext/zlib/zlib.c diff -u php4/ext/zlib/zlib.c:1.38 php4/ext/zlib/zlib.c:1.39 --- php4/ext/zlib/zlib.c:1.38 Thu Apr 20 09:59:55 2000 +++ php4/ext/zlib/zlib.c Thu Apr 20 10:24:01 2000 @@ -16,7 +16,7 @@ | Stefan Röhrich <sr@linux.de> | +----------------------------------------------------------------------+ */ -/* $Id: zlib.c,v 1.38 2000/04/20 16:59:55 fmk Exp $ */ +/* $Id: zlib.c,v 1.39 2000/04/20 17:24:01 zeev Exp $ */ #define IS_EXT_MODULE #include "php.h" @@ -206,7 +206,7 @@ if(PG(doc_root)) { snprintf(trypath, MAXPATHLEN, "%s%s", PG(doc_root), filename); } else { - strncpy(trypath,filename,sizeof(trypath)); + strlcpy(trypath,filename,sizeof(trypath)); } if (!php_checkuid(trypath,2)) { return(NULL); @@ -251,7 +251,7 @@ } snprintf(trypath, MAXPATHLEN, "%s/%s", ptr, filename); if (PG(safe_mode)) { - if (stat(trypath,&sb) == 0 &&(!php_checkuid(trypath,2))) { + if (V_STAT(trypath,&sb) == 0 &&(!php_checkuid(trypath,2))) { efree(pathbuf); return(NULL); }

« previous php.version4 (#13812) next »