Commit eee28563404 for php
commit eee28563404c2fe8cd3d4ccd3eaf2e59e69cb16d
Author: Marc Bennewitz <marc-mabe@users.noreply.github.com>
Date: Mon Nov 2 16:37:52 2026 +0100
Add test for Phar::buildFromIterator() with a negative getMTime() (#24779)
The fix of ZEND_LONG_UINT_OVFL() on 32-bit platforms also makes
Phar::buildFromIterator() reject a negative timestamp there.
diff --git a/NEWS b/NEWS
index 42912edae90..49e7f68744e 100644
--- a/NEWS
+++ b/NEWS
@@ -184,6 +184,8 @@ PHP NEWS
mounted entries). (Lazizbek Ergashev)
. Fixed bug GH-24531 (Crash when modifying a zip-based phar whose file was
renamed). (Ilia Alshanetsky)
+ . Fixed Phar::buildFromIterator() accepting a negative getMTime() on 32bit
+ platforms. (Marc Bennewitz)
- Reflection:
. Fixed bug GH-21768 (Assertion failure in ReflectionProperty::isReadable()
diff --git a/ext/phar/tests/buildFromIterator_user_overrides/getMTime_negative.phpt b/ext/phar/tests/buildFromIterator_user_overrides/getMTime_negative.phpt
new file mode 100644
index 00000000000..31570578164
--- /dev/null
+++ b/ext/phar/tests/buildFromIterator_user_overrides/getMTime_negative.phpt
@@ -0,0 +1,53 @@
+--TEST--
+buildFromIterator with user overrides - negative getMTime()
+--EXTENSIONS--
+phar
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+class MySplFileInfo extends SplFileInfo {
+ public function getMTime(): int|false {
+ echo "[MTime]\n";
+ return -1;
+ }
+}
+
+class MyIterator extends RecursiveDirectoryIterator {
+ public function current(): SplFileInfo {
+ return new MySplFileInfo(parent::current()->getPathname());
+ }
+}
+
+$workdir = __DIR__.'/getMTime_negative';
+mkdir($workdir . '/content', recursive: true);
+file_put_contents($workdir . '/content/hello.txt', "Hello world.");
+
+try {
+ $phar = new \Phar($workdir . "/test.phar");
+ $phar->startBuffering();
+ $phar->buildFromIterator(
+ new RecursiveIteratorIterator(
+ new MyIterator($workdir . '/content', FilesystemIterator::SKIP_DOTS)
+ ),
+ $workdir
+ );
+ $phar->stopBuffering();
+} catch (Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), "\n";
+}
+
+?>
+--CLEAN--
+<?php
+$workdir = __DIR__.'/getMTime_negative';
+@unlink($workdir . '/content/hello.txt');
+@unlink($workdir . '/test.phar');
+@rmdir($workdir . '/content');
+@rmdir($workdir);
+?>
+--EXPECTF--
+[MTime]
+BadMethodCallException: Entry content%chello.txt cannot be created: timestamp is limited to 32-bit