diff options
author | Anatol Belski <ab@php.net> | 2016-09-11 12:36:58 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2016-09-11 12:59:43 +0200 |
commit | d947d974d598a35f08a6a9057ffc3dffac72c6c2 (patch) | |
tree | ecd1cdc9d0efbb6f27514182ebc0bcb5ca165362 | |
parent | ed51f3479502f11ab200390c245b883d22bf760c (diff) | |
download | php-git-d947d974d598a35f08a6a9057ffc3dffac72c6c2.tar.gz |
Revert "Revert "Merge branch 'PHP-5.6' into PHP-7.0""
This reverts commit 62d5bfb5277dd84e1a185c567982f2196cd19437.
-rw-r--r-- | ext/standard/file.c | 5 | ||||
-rw-r--r-- | ext/standard/tests/file/bug71882.phpt | 11 |
2 files changed, 16 insertions, 0 deletions
diff --git a/ext/standard/file.c b/ext/standard/file.c index 5c90b30559..e228ce6121 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -1546,6 +1546,11 @@ PHP_NAMED_FUNCTION(php_if_ftruncate) RETURN_FALSE; } + if (size < 0) { + php_error_docref(NULL, E_WARNING, "Negative size is not supported"); + RETURN_FALSE; + } + PHP_STREAM_TO_ZVAL(stream, fp); if (!php_stream_truncate_supported(stream)) { diff --git a/ext/standard/tests/file/bug71882.phpt b/ext/standard/tests/file/bug71882.phpt new file mode 100644 index 0000000000..ae0137b599 --- /dev/null +++ b/ext/standard/tests/file/bug71882.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #71882 (Negative ftruncate() on php://memory exhausts memory) +--FILE-- +<?php +$fd = fopen("php://memory", "w+"); +ftruncate($fd, -1); +?> +==DONE== +--EXPECTF-- +Warning: ftruncate(): Negative size is not supported in %s%ebug71882.php on line %d +==DONE== |