From: Andi Gutmans Date: Thu, 30 Mar 2000 22:38:50 +0000 (+0000) Subject: - Fix another bug in session.c X-Git-Tag: php-4.0RC2~561 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f9547241d56b4b9b5ecc81600e21ab55854bc7ba;p=php - Fix another bug in session.c - Start using the new PHP_GETCWD() and co. macros --- diff --git a/ext/session/session.c b/ext/session/session.c index ef7201dd9a..0c268ede5d 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -889,7 +889,7 @@ PHP_FUNCTION(session_get_cookie_params) RETURN_FALSE; } - add_assoc_string(return_value, "lifetime", PS(cookie_lifetime), 1); + add_assoc_long(return_value, "lifetime", PS(cookie_lifetime)); add_assoc_string(return_value, "path", PS(cookie_path), 1); add_assoc_string(return_value, "domain", PS(cookie_domain), 1); } diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index f4081ce7f7..9ab09104e1 100644 --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -970,7 +970,7 @@ PHPAPI char *expand_filepath(char *filepath) if (filepath[0] == '.') { char *cwd = malloc(MAXPATHLEN + 1); - if (getcwd(cwd, MAXPATHLEN)) { + if (PHP_GETCWD(cwd, MAXPATHLEN)) { char *cwd_end = cwd + strlen(cwd); if (filepath[1] == '.') { /* parent directory - .. */ diff --git a/main/php.h b/main/php.h index 4bbb694b5f..484d8af81f 100644 --- a/main/php.h +++ b/main/php.h @@ -284,6 +284,16 @@ PHPAPI int cfg_get_string(char *varname, char **result); #define PUTS_H(str) php_header_write((str), strlen((str))) #define PUTC_H(c) (php_header_write(&(c), 1), (c)) +/* Virtual current directory support */ +#ifdef VIRTUAL_DIR +#define PHP_GETCWD(buff, size) virtual_getcwd(buff,size) +#define PHP_FOPEN(path, mode) virtual_fopen(path, mode) +#define PHP_CHDIR(path) virtual_chdir(path) +#else +#define PHP_GETCWD(buff, size) getcwd(buff,size) +#define PHP_FOPEN(path, mode) fopen(path, mode) +#define PHP_CHDIR(path) chdir(path) +#endif #include "zend_constants.h" diff --git a/main/php_realpath.c b/main/php_realpath.c index 9ced9b4030..b134b3fce3 100644 --- a/main/php_realpath.c +++ b/main/php_realpath.c @@ -63,7 +63,7 @@ char *php_realpath(char *path, char resolved_path []) { if ((*workpos == '\\') || (*workpos == '/')) { /* We start at the root of the current drive */ /* Get the current directory */ - if (getcwd(path_construction, MAXPATHLEN-1) == NULL) { + if (PHP_GETCWD(path_construction, MAXPATHLEN-1) == NULL) { /* Unable to get cwd */ resolved_path[0] = 0; return NULL; @@ -79,7 +79,7 @@ char *php_realpath(char *path, char resolved_path []) { workpos++; } else { /* Use the current directory */ - if (getcwd(path_construction, MAXPATHLEN-1) == NULL) { + if (PHP_GETCWD(path_construction, MAXPATHLEN-1) == NULL) { /* Unable to get cwd */ resolved_path[0] = 0; return NULL; @@ -94,7 +94,7 @@ char *php_realpath(char *path, char resolved_path []) { workpos++; } else { /* Use the current directory */ - if (getcwd(path_construction, MAXPATHLEN-1) == NULL) { + if (PHP_GETCWD(path_construction, MAXPATHLEN-1) == NULL) { /* Unable to get cwd */ resolved_path[0] = 0; return NULL; diff --git a/main/safe_mode.c b/main/safe_mode.c index ab026376ba..b072552787 100644 --- a/main/safe_mode.c +++ b/main/safe_mode.c @@ -88,7 +88,7 @@ PHPAPI int php_checkuid(const char *fn, int mode) { duid = sb.st_uid; } else { s = emalloc(MAXPATHLEN+1); - if (!getcwd(s,MAXPATHLEN)) { + if (!PHP_GETCWD(s,MAXPATHLEN)) { php_error(E_WARNING, "Unable to access current working directory"); return(0); }