]> granicus.if.org Git - php/commitdiff
Fixed Bug #43248 (backward compatibility break in realpath())
authorDmitry Stogov <dmitry@php.net>
Tue, 13 Nov 2007 09:46:39 +0000 (09:46 +0000)
committerDmitry Stogov <dmitry@php.net>
Tue, 13 Nov 2007 09:46:39 +0000 (09:46 +0000)
NEWS
TSRM/tsrm_virtual_cwd.c
ext/standard/tests/file/bug43248.phpt [new file with mode: 0755]

diff --git a/NEWS b/NEWS
index d55182bbbb208cdb62edac90e7f6795517729f4a..2252216f4d0e042f794d63fd347c63a9d1f5c8cb 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
 PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 2008, PHP 5.2.6
+- Fixed bug #43248 (backward compatibility break in realpath()). (Dmitry)
 - Fixed bug #43221 (SimpleXML adding default namespace in addAttribute). (Rob)
 - Fixed bug #43216 (stream_is_local() returns false on "file://"). (Dmitry)
 - Fixed bug #43201 (Crash on using unitialized vals and __get/__set). (Dmitry)
index 6ed33bdea2d0e7cc95c76e25a213c53cf4a9bd48..0401493e62b20336ad57ff38fc1d2f230c8b0b6e 100644 (file)
@@ -712,22 +712,24 @@ no_realpath:
                        }
                        ptr = tsrm_strtok_r(NULL, TOKENIZER_STRING, &tok);
                }
+               free(free_path);
+
+               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] == '/') {
+                       if (path[path_length-1] == '\\' || path[path_length-1] == '/') {
 #else 
-               if (path[path_length-1] == '/') {
+                       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;
+                               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 (executable)
index 0000000..a20e0e0
--- /dev/null
@@ -0,0 +1,8 @@
+--TEST--
+Bug #43248 backward compatibility break in realpath() 
+--FILE--
+<?php
+echo realpath(dirname(__FILE__) . '/../file/');
+?>
+--EXPECTF--
+%sfile