]> granicus.if.org Git - php/commitdiff
Fixed bug #45835 (include and symlinks)
authorDmitry Stogov <dmitry@php.net>
Mon, 18 Aug 2008 10:28:00 +0000 (10:28 +0000)
committerDmitry Stogov <dmitry@php.net>
Mon, 18 Aug 2008 10:28:00 +0000 (10:28 +0000)
TSRM/tsrm_virtual_cwd.c
ext/standard/tests/file/realpath_basic4.phpt [new file with mode: 0755]

index 5cf0d83ad74e5ca9cb57d33866ac8b3a4e8f3823..804c94b9f5c42b8b6f136a5426283297cb4bd60c 100644 (file)
@@ -587,6 +587,9 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
                                        /* not a directory */
                                        return -1;
                        } else {
+                               if (link_is_dir) {
+                                       *link_is_dir = bucket->is_dir;
+                               }
                                        memcpy(path, bucket->realpath, bucket->realpath_len + 1);
                                    return bucket->realpath_len;
                                }
@@ -656,6 +659,9 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
                                        return -1;
                                }
                        }
+                       if (link_is_dir) {
+                               *link_is_dir = directory;
+                       }
                } else {
                        if (save) {
                                directory = S_ISDIR(st.st_mode);
diff --git a/ext/standard/tests/file/realpath_basic4.phpt b/ext/standard/tests/file/realpath_basic4.phpt
new file mode 100755 (executable)
index 0000000..d782b6d
--- /dev/null
@@ -0,0 +1,29 @@
+--TEST--
+Test realpath() with relative paths
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip no symlinks on Windows');
+}
+?>
+--FILE--
+<?php
+$file_path = dirname(__FILE__);
+@mkdir("$file_path/realpath_basic/home/test", 0777, true);
+@symlink("$file_path/realpath_basic/home", "$file_path/realpath_basic/link1");
+@symlink("$file_path/realpath_basic/link1", "$file_path/realpath_basic/link2");
+echo "1. " . realpath("$file_path/realpath_basic/link2") . "\n";
+echo "2. " . realpath("$file_path/realpath_basic/link2/test") . "\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/realpath_basic/link2");
+unlink("$file_path/realpath_basic/link1");
+rmdir("$file_path/realpath_basic/home/test");
+rmdir("$file_path/realpath_basic/home");
+rmdir("$file_path/realpath_basic");
+?>
+--EXPECTF--
+1. %s%erealpath_basic%ehome
+2. %s%erealpath_basic%ehome%etest