[php-src] master: Merge branch 'PHP-8.6'
| From: | Jorg Sowa | Date: | Wed, 25 Nov 2026 09:14:26 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.6' | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-144152@lists.php.net to get a copy of this message | ||
Author: Jorg Sowa (jorgsowa)
Date: 2026-11-25T10:12:44+01:00
Commit: https://github.com/php/php-src/commit/658a61a349a4be6c40edb7acae8bfb2150506566
Raw diff: https://github.com/php/php-src/commit/658a61a349a4be6c40edb7acae8bfb2150506566.diff
Merge branch 'PHP-8.6'
# Conflicts:
# NEWS
Changed paths:
A ext/session/tests/mod_files/gc_dirdepth_symlink.phpt
M ext/session/mod_files.c
Diff:
diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c
index 4528ebb70bcf..d3a707b4b9c5 100644
--- a/ext/session/mod_files.c
+++ b/ext/session/mod_files.c
@@ -327,8 +327,8 @@ static int ps_files_cleanup_dir(const zend_string *dirname, zend_long maxlifetim
nrdels++;
}
} else {
- /* intermediate depth: recurse into subdirectories */
- if (VCWD_STAT(buf, &sbuf) != 0) {
+ /* intermediate depth: recurse into subdirectories, never through symlinks */
+ if (VCWD_LSTAT(buf, &sbuf) != 0) {
continue;
}
if (S_ISDIR(sbuf.st_mode)) {
diff --git a/ext/session/tests/mod_files/gc_dirdepth_symlink.phpt
b/ext/session/tests/mod_files/gc_dirdepth_symlink.phpt
new file mode 100644
index 000000000000..532bc3b77963
--- /dev/null
+++ b/ext/session/tests/mod_files/gc_dirdepth_symlink.phpt
@@ -0,0 +1,45 @@
+--TEST--
+session GC with save_path dirdepth does not follow symlinked subdirectories
+--EXTENSIONS--
+session
+--SKIPIF--
+<?php
+include(__DIR__ . '/../skipif.inc');
+$probe = __DIR__ . '/gc_dirdepth_symlink_probe';
+@mkdir($probe);
+$ok = @symlink($probe, "$probe.lnk");
+@rmdir("$probe.lnk") || @unlink("$probe.lnk");
+@rmdir($probe);
+if (!$ok) die('skip cannot create directory symlinks');
+?>
+--INI--
+session.gc_probability=0
+session.gc_maxlifetime=10
+session.use_strict_mode=0
+--FILE--
+<?php
+$base = __DIR__ . '/gc_dirdepth_symlink';
+$outside = "$base-outside";
+@mkdir("$base/b", 0777, true);
+@mkdir($outside);
+symlink($outside, "$base/a");
+touch("$outside/sess_a", time() - 2000);
+
+session_save_path("1;$base");
+session_id('b0');
+session_start();
+var_dump(session_gc(), file_exists("$outside/sess_a"));
+?>
+--CLEAN--
+<?php
+$base = __DIR__ . '/gc_dirdepth_symlink';
+@unlink("$base/b/sess_b0");
+@rmdir("$base/a") || @unlink("$base/a");
+@rmdir("$base/b");
+@rmdir($base);
+@unlink("$base-outside/sess_a");
+@rmdir("$base-outside");
+?>
+--EXPECT--
+int(0)
+bool(true)