]> granicus.if.org Git - php/commitdiff
- Add missing V_STAT()
authorAndi Gutmans <andi@php.net>
Thu, 20 Apr 2000 16:38:08 +0000 (16:38 +0000)
committerAndi Gutmans <andi@php.net>
Thu, 20 Apr 2000 16:38:08 +0000 (16:38 +0000)
main/SAPI.c
main/fopen_wrappers.c
main/php.h
main/php_realpath.c
main/php_virtual_cwd.c
main/php_virtual_cwd.h
main/safe_mode.c

index 3f29c977691930842a04046205cdde715bd03e9d..e2f58790ff4ed918093c481964cc22f43b1e1fbf 100644 (file)
@@ -534,7 +534,7 @@ SAPI_API struct stat *sapi_get_stat()
        if (sapi_module.get_stat) {
                return sapi_module.get_stat(SLS_C);
        } else {
-               if (!SG(request_info).path_translated || (stat(SG(request_info).path_translated, &SG(global_stat))==-1)) {
+               if (!SG(request_info).path_translated || (V_STAT(SG(request_info).path_translated, &SG(global_stat))==-1)) {
                        return NULL;
                }
                return &SG(global_stat);
index bce69d9728401a5dd6f9a44798f34a9955674c1f..a3473be22722ac7b762d980015c7e41818257a87 100644 (file)
@@ -408,7 +408,7 @@ PHPAPI FILE *php_fopen_with_path(char *filename, char *mode, char *path, char **
                }
                snprintf(trypath, MAXPATHLEN, "%s/%s", ptr, filename);
                if (PG(safe_mode)) {
-                       if (stat(trypath, &sb) == 0 && (!php_checkuid(trypath, cm))) {
+                       if (V_STAT(trypath, &sb) == 0 && (!php_checkuid(trypath, cm))) {
                                efree(pathbuf);
                                return NULL;
                        }
index 89968361f1e5bd69d572b122246c5e6def24b189..db23919e216188cfc7b2efc0788e1f898bd07fa4 100644 (file)
@@ -294,12 +294,14 @@ PHPAPI int cfg_get_string(char *varname, char **result);
 #define V_CHDIR(path) virtual_chdir(path)
 #define V_CHDIR_FILE(path) virtual_chdir_file(path)
 #define V_GETWD(buf)
+#define V_STAT(path, buff) virtual_stat(path, buff)
 #else
 #define V_GETCWD(buff, size) getcwd(buff,size)
 #define V_FOPEN(path, mode)  fopen(path, mode)
 #define V_CHDIR(path) chdir(path)
 #define V_CHDIR_FILE(path) chdir_file(path)
 #define V_GETWD(buf) getwd(buf)
+#define V_STAT(path, buff) stat(path, buff)
 #endif
 
 #include "zend_constants.h"
index d60efa362c2782b67ce180a03a3ca3703c3d83b9..66dfe5e9ca72b218bad1c596f41fbb1e814b876f 100644 (file)
@@ -251,7 +251,7 @@ char *php_realpath(char *path, char resolved_path []) {
        }
 
        /* Check if the resolved path is a directory */
-       if (stat(path_construction, &filestat) != 0) return NULL;
+       if (V_STAT(path_construction, &filestat) != 0) return NULL;
        if (S_ISDIR(filestat.st_mode)) {
                /* It's a directory, append a / if needed */
                if (*(writepos-1) != '/') {
index e773fde9ee0dc87dc8cd94c656db18126a1aa776..3613cc77f85f7c09d94c9b6f5d691a4facf3f8e7 100644 (file)
@@ -7,6 +7,7 @@
 #include <stdlib.h>
 #include <ctype.h>
 
+
 #include "php_virtual_cwd.h"
 
 #ifdef ZTS
@@ -366,6 +367,21 @@ CWD_API FILE *virtual_fopen(const char *path, const char *mode)
        return f;
 }
 
+CWD_API int virtual_stat(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 = stat(new_state.cwd, buf);
+       CWD_STATE_FREE(&new_state);
+       return retval;
+}
+
 #if 0
 
 main(void)
index ab46974d710a22579b5908993ecb8dc82ee0b48f..a7548c8d59b4e9677be8d5e680cda844b74e8d48 100644 (file)
@@ -4,6 +4,14 @@
 #include "zend.h"
 #include "zend_API.h"
 
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#ifndef ZEND_WIN32
+#include <unistd.h>
+#endif
+
+
 #ifdef PHP_EXPORTS
 #define CWD_EXPORTS
 #endif
@@ -34,6 +42,7 @@ CWD_API int virtual_chdir(char *path);
 CWD_API int virtual_chdir_file(char *path);
 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_file_ex(cwd_state *state, const char *path, verify_path_func verify_path);
 
 ZEND_BEGIN_MODULE_GLOBALS(cwd)
index ac33ba88db000d65ff9874077637115225e8da8d..4f4344291c03c260ded5288f3f8617c15bc9757f 100644 (file)
@@ -57,7 +57,7 @@ PHPAPI int php_checkuid(const char *fn, int mode) {
        }
                
        if (mode<3) {
-               ret = stat(fn,&sb);
+               ret = V_STAT(fn,&sb);
                if (ret<0 && mode < 2) {
                        php_error(E_WARNING,"Unable to access %s",fn);
                        return(mode);
@@ -79,7 +79,7 @@ PHPAPI int php_checkuid(const char *fn, int mode) {
 
        if (s) {
                *s='\0';
-               ret = stat(fn,&sb);
+               ret = V_STAT(fn,&sb);
                *s='/';
                if (ret<0) {
                        php_error(E_WARNING, "Unable to access %s",fn);
@@ -92,7 +92,7 @@ PHPAPI int php_checkuid(const char *fn, int mode) {
                        php_error(E_WARNING, "Unable to access current working directory");
                        return(0);
                }
-               ret = stat(s,&sb);
+               ret = V_STAT(s,&sb);
                efree(s);
                if (ret<0) {
                        php_error(E_WARNING, "Unable to access %s",s);