]> granicus.if.org Git - php/commitdiff
reverted some previous IS_ABSOLUTE_PATH related changes
authorAnatol Belski <ab@php.net>
Fri, 19 Sep 2014 13:59:55 +0000 (15:59 +0200)
committerAnatol Belski <ab@php.net>
Fri, 19 Sep 2014 14:30:05 +0000 (16:30 +0200)
It's fine with strlen usage now, only one call

TSRM/tsrm_win32.c
Zend/zend_virtual_cwd.c
main/fopen_wrappers.c

index 7a7ab5dfcb38be29e4d35b38f2ad74284e7e398e..0b8228aafb84fda9fec62b61a7ceb0578c555148 100644 (file)
@@ -212,8 +212,7 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode TSRMLS_DC)
                DWORD type;
                return GetBinaryType(pathname, &type) ? 0 : -1;
        } else {
-               size_t pathname_len = strlen(pathname) + 1;
-               if(!IS_ABSOLUTE_PATH(pathname, pathname_len)) {
+               if(!IS_ABSOLUTE_PATH(pathname, strlen(pathname)+1)) {
                        real_path = (char *)malloc(MAX_PATH);
                        if(tsrm_realpath(pathname, real_path TSRMLS_CC) == NULL) {
                                goto Finished;
index dabe6b5fe94e2fe91192537416a667c57a5bab4d..665829d685c96242f308a677d478c33381cee6c7 100644 (file)
@@ -1442,20 +1442,16 @@ CWD_API char *virtual_realpath(const char *path, char *real_path TSRMLS_DC) /* {
                if (VCWD_GETCWD(cwd, MAXPATHLEN)) {
                        path = cwd;
                }
+       } else if (!IS_ABSOLUTE_PATH(path, strlen(path))) {
+               CWD_STATE_COPY(&new_state, &CWDG(cwd));
        } else {
-               size_t path_len = strlen(path);
-
-               if (!IS_ABSOLUTE_PATH(path, path_len)) {
-                       CWD_STATE_COPY(&new_state, &CWDG(cwd));
-               } else {
-                       new_state.cwd = (char*)emalloc(1);
-                       if (new_state.cwd == NULL) {
-                               retval = NULL;
-                               goto end;
-                       }
-                       new_state.cwd[0] = '\0';
-                       new_state.cwd_length = 0;
+               new_state.cwd = (char*)emalloc(1);
+               if (new_state.cwd == NULL) {
+                       retval = NULL;
+                       goto end;
                }
+               new_state.cwd[0] = '\0';
+               new_state.cwd_length = 0;
        }
 
        if (virtual_file_ex(&new_state, path, NULL, CWD_REALPATH TSRMLS_CC)==0) {
@@ -1971,21 +1967,17 @@ CWD_API char *tsrm_realpath(const char *path, char *real_path TSRMLS_DC) /* {{{
                if (VCWD_GETCWD(cwd, MAXPATHLEN)) {
                        path = cwd;
                }
+       } else if (!IS_ABSOLUTE_PATH(path, strlen(path)) &&
+                                       VCWD_GETCWD(cwd, MAXPATHLEN)) {
+               new_state.cwd = estrdup(cwd);
+               new_state.cwd_length = strlen(cwd);
        } else {
-               size_t path_len = strlen(path);
-
-               if (!IS_ABSOLUTE_PATH(path, path_len) &&
-                       VCWD_GETCWD(cwd, MAXPATHLEN)) {
-                       new_state.cwd = estrdup(cwd);
-                       new_state.cwd_length = strlen(cwd);
-               } else {
-                       new_state.cwd = (char*)emalloc(1);
-                       if (new_state.cwd == NULL) {
-                               return NULL;
-                       }
-                       new_state.cwd[0] = '\0';
-                       new_state.cwd_length = 0;
+               new_state.cwd = (char*)emalloc(1);
+               if (new_state.cwd == NULL) {
+                       return NULL;
                }
+               new_state.cwd[0] = '\0';
+               new_state.cwd_length = 0;
        }
 
        if (virtual_file_ex(&new_state, path, NULL, CWD_REALPATH TSRMLS_CC)) {
index a4aa10fce87b1e1c256acb4cffa215cc51e6aaad..7afa04c7d5abaee5e4abb4d67e03f848b0f9058f 100644 (file)
@@ -759,15 +759,11 @@ PHPAPI char *expand_filepath_with_mode(const char *filepath, char *real_path, co
        cwd_state new_state;
        char cwd[MAXPATHLEN];
        int copy_len;
-       int path_len;
+       int path_len = (int)strlen(filepath);
 
        if (!filepath[0]) {
                return NULL;
-       }
-
-       path_len = (int)strlen(filepath);
-
-       if (IS_ABSOLUTE_PATH(filepath, path_len)) {
+       } else if (IS_ABSOLUTE_PATH(filepath, path_len)) {
                cwd[0] = '\0';
        } else {
                const char *iam = SG(request_info).path_translated;