From: Dmitry Stogov Date: Tue, 13 Nov 2007 09:47:06 +0000 (+0000) Subject: Fixed bug #43248 (backward compatibility break in realpath()) X-Git-Tag: RELEASE_1_3_1~656 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=947e73b385dfcc0db18782791265209abdb167c0;p=php Fixed bug #43248 (backward compatibility break in realpath()) --- diff --git a/TSRM/tsrm_virtual_cwd.c b/TSRM/tsrm_virtual_cwd.c index 6ed33bdea2..e808f85b6e 100644 --- a/TSRM/tsrm_virtual_cwd.c +++ b/TSRM/tsrm_virtual_cwd.c @@ -712,22 +712,25 @@ no_realpath: } ptr = tsrm_strtok_r(NULL, TOKENIZER_STRING, &tok); } -#if defined(TSRM_WIN32) || defined(NETWARE) - if (path[path_length-1] == '\\' || path[path_length-1] == '/') { -#else - if (path[path_length-1] == '/') { -#endif - state->cwd = (char*)realloc(state->cwd, state->cwd_length + 2); - state->cwd[state->cwd_length++] = DEFAULT_SLASH; - state->cwd[state->cwd_length] = 0; - } free(free_path); - if ((use_realpath == CWD_REALPATH) && ret) { - CWD_STATE_FREE(state); - *state = old_state; - return 1; + if (use_realpath == CWD_REALPATH) { + if (ret) { + CWD_STATE_FREE(state); + *state = old_state; + return 1; + } + } else { +#if defined(TSRM_WIN32) || defined(NETWARE) + if (path[path_length-1] == '\\' || path[path_length-1] == '/') { +#else + if (path[path_length-1] == '/') { +#endif + state->cwd = (char*)realloc(state->cwd, state->cwd_length + 2); + state->cwd[state->cwd_length++] = DEFAULT_SLASH; + state->cwd[state->cwd_length] = 0; + } } if (state->cwd_length == COPY_WHEN_ABSOLUTE(state->cwd)) { diff --git a/ext/standard/tests/file/bug43248.phpt b/ext/standard/tests/file/bug43248.phpt new file mode 100755 index 0000000000..a20e0e06c4 --- /dev/null +++ b/ext/standard/tests/file/bug43248.phpt @@ -0,0 +1,8 @@ +--TEST-- +Bug #43248 backward compatibility break in realpath() +--FILE-- + +--EXPECTF-- +%sfile