Skip to content

Commit

Permalink
reverted some previous IS_ABSOLUTE_PATH related changes
Browse files Browse the repository at this point in the history
It's fine with strlen usage now, only one call
  • Loading branch information
weltling committed Sep 19, 2014
1 parent 149db93 commit d1131d4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 33 deletions.
3 changes: 1 addition & 2 deletions TSRM/tsrm_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
42 changes: 17 additions & 25 deletions Zend/zend_virtual_cwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)) {
Expand Down
8 changes: 2 additions & 6 deletions main/fopen_wrappers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d1131d4

Please sign in to comment.