mirror of
https://github.com/php/php-src.git
synced 2026-04-24 00:18:23 +02:00
d59aac58b3
The php_stream_read() and php_stream_write() functions now return an ssize_t value, with negative results indicating failure. Functions like fread() and fwrite() will return false in that case. As a special case, EWOULDBLOCK and EAGAIN on non-blocking streams should not be regarded as error conditions, and be reported as successful zero-length reads/writes instead. The handling of EINTR remains unclear and is internally inconsistent (e.g. some code-paths will automatically retry on EINTR, while some won't). I'm landing this now to make sure the stream wrapper ops API changes make it into 7.4 -- however, if the user-facing changes turn out to be problematic we have the option of clamping negative returns to zero in php_stream_read() and php_stream_write() to restore the old behavior in a relatively non-intrusive manner.
25 lines
614 B
PHP
25 lines
614 B
PHP
--TEST--
|
|
Bug #52944 (segfault with zlib filter and corrupted data)
|
|
--SKIPIF--
|
|
<?php if (!extension_loaded("zlib")) print "skip"; ?>
|
|
--INI--
|
|
allow_url_fopen=1
|
|
--FILE--
|
|
<?php
|
|
/* NOTE this test can fail on asm builds of zlib 1.2.5 or
|
|
1.2.7 on at least Windows and Darwin. Using unoptimized
|
|
zlib build fixes the issue. */
|
|
|
|
require __DIR__ . "/bug_52944_corrupted_data.inc";
|
|
|
|
$fp = fopen('data://text/plain;base64,' . $data, 'r');
|
|
stream_filter_append($fp, 'zlib.inflate', STREAM_FILTER_READ);
|
|
var_dump(fread($fp,1));
|
|
var_dump(fread($fp,1));
|
|
fclose($fp);
|
|
echo "Done.\n";
|
|
--EXPECT--
|
|
bool(false)
|
|
string(0) ""
|
|
Done.
|