com php-src: reverted some previous IS_ABSOLUTE_PATH rela ted changes: TSRM/tsrm_win32.c Zend/zend_virt ual_cwd.c main/fopen_wrappers.c
| From: | Anatol Belski | Date: | Fri, 19 Sep 2014 14:30:05 +0000 |
| Subject: | com php-src: reverted some previous IS_ABSOLUTE_PATH rela ted changes: TSRM/tsrm_win32.c Zend/zend_virt ual_cwd.c main/fopen_wrappers.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-81776@lists.php.net to get a copy of this message | ||
Commit: d1131d4278ce645d359aa74ee549183beff545a4
Author: Anatol Belski <ab@php.net> Fri, 19 Sep 2014 15:59:55 +0200
Parents: 149db936d43ba31bb41da62b0d26d510f32514ee
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d1131d4278ce645d359aa74ee549183beff545a4
Log:
reverted some previous IS_ABSOLUTE_PATH related changes
It's fine with strlen usage now, only one call
Changed paths:
M TSRM/tsrm_win32.c
M Zend/zend_virtual_cwd.c
M main/fopen_wrappers.c
Diff:
diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c
index 7a7ab5d..0b8228a 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 dabe6b5..665829d 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 a4aa10f..7afa04c 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;