Fix #81294: Segfault when removing a filter

We need to call the proper method.

Closes GH-7308.
This commit is contained in:
Christoph M. Becker 2021-07-26 14:12:02 +02:00
parent 387c0de983
commit 1fa26eccba
No known key found for this signature in database
GPG key ID: D66C9593118BCCB6
3 changed files with 28 additions and 1 deletions

3
NEWS
View file

@ -22,6 +22,9 @@ PHP NEWS
(George Dietrich)
. Fixed bug #74960 (Heap buffer overflow via str_repeat). (cmb, Dmitry)
- Streams:
. Fixed bug #81294 (Segfault when removing a filter). (cmb)
29 Jul 2021, PHP 7.4.22
- Core:

View file

@ -0,0 +1,24 @@
--TEST--
Bug #81294 (Segfault when removing a filter)
--SKIPIF--
<?php
if (!extension_loaded('zlib')) die("skip zlib extension not available");
?>
--FILE--
<?php
$f = fopen(__DIR__ . "/bug81294.txt", "wb+");
$flt1 = stream_filter_append($f, "zlib.deflate", STREAM_FILTER_WRITE);
$flt2 = stream_filter_append($f, "string.rot13", STREAM_FILTER_WRITE);
fwrite($f, "test");
stream_filter_remove($flt1);
fwrite($f, "test");
stream_filter_remove($flt2);
rewind($f);
var_dump(urlencode(fread($f, 1024)));
?>
--CLEAN--
<?php
@unlink(__DIR__ . "/bug81294.txt");
?>
--EXPECT--
string(16) "%2BV-.%01%00grfg"

View file

@ -418,7 +418,7 @@ PHPAPI int _php_stream_filter_flush(php_stream_filter *filter, int finish)
for(current = filter; current; current = current->next) {
php_stream_filter_status_t status;
status = filter->fops->filter(stream, current, inp, outp, NULL, flags);
status = current->fops->filter(stream, current, inp, outp, NULL, flags);
if (status == PSFS_FEED_ME) {
/* We've flushed the data far enough */
return SUCCESS;