diff options
author | Anatol Belski <ab@php.net> | 2014-09-19 15:59:55 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2014-09-19 16:30:05 +0200 |
commit | d1131d4278ce645d359aa74ee549183beff545a4 (patch) | |
tree | 20682478da89cc92596858ee07969ae49056aa1a | |
parent | 149db936d43ba31bb41da62b0d26d510f32514ee (diff) | |
download | php-git-d1131d4278ce645d359aa74ee549183beff545a4.tar.gz |
reverted some previous IS_ABSOLUTE_PATH related changes
It's fine with strlen usage now, only one call
-rw-r--r-- | TSRM/tsrm_win32.c | 3 | ||||
-rw-r--r-- | Zend/zend_virtual_cwd.c | 42 | ||||
-rw-r--r-- | main/fopen_wrappers.c | 8 |
3 files changed, 20 insertions, 33 deletions
diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c index 7a7ab5dfcb..0b8228aafb 100644 --- a/TSRM/tsrm_win32.c +++ b/TSRM/tsrm_win32.c @@ -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; diff --git a/Zend/zend_virtual_cwd.c b/Zend/zend_virtual_cwd.c index dabe6b5fe9..665829d685 100644 --- a/Zend/zend_virtual_cwd.c +++ b/Zend/zend_virtual_cwd.c @@ -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)) { diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index a4aa10fce8..7afa04c7d5 100644 --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -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; |