mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.3' into PHP-8.4
This commit is contained in:
@@ -2684,6 +2684,12 @@ PHP_METHOD(SplFileObject, ftruncate)
|
||||
|
||||
CHECK_SPL_FILE_OBJECT_IS_INITIALIZED(intern);
|
||||
|
||||
if (size < 0) {
|
||||
zend_argument_value_error(1, "must be greater than or equal to 0");
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
|
||||
if (!php_stream_truncate_supported(intern->u.file.stream)) {
|
||||
zend_throw_exception_ex(spl_ce_LogicException, 0, "Can't truncate file %s", ZSTR_VAL(intern->file_name));
|
||||
RETURN_THROWS();
|
||||
|
||||
16
ext/spl/tests/gh17463.phpt
Normal file
16
ext/spl/tests/gh17463.phpt
Normal file
@@ -0,0 +1,16 @@
|
||||
--TEST--
|
||||
GH-17463 segfault on SplFileObject::ftruncate() with negative value.
|
||||
--CREDITS--
|
||||
YuanchengJiang
|
||||
--FILE--
|
||||
<?php
|
||||
$cls = new SplTempFileObject();
|
||||
|
||||
try {
|
||||
$cls->ftruncate(-1);
|
||||
} catch (\ValueError $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
SplFileObject::ftruncate(): Argument #1 ($size) must be greater than or equal to 0
|
||||
Reference in New Issue
Block a user