Skip to content

Commit d757be6

Browse files
committed
Fix #71263: fread() does not report bzip2.decompress errors
If the bzip2.decompress filter fails to decompress the stream, we raise a notice instead of failing silently.
1 parent 6111d64 commit d757be6

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ PHP NEWS
2121
. Fixed bug #79368 ("Unexpected end of file" is not an acceptable error
2222
message). (Alex Dowad)
2323

24+
- BZ2:
25+
. Fixed bug #71263 (fread() does not report bzip2.decompress errors). (cmb)
26+
2427
- CURL:
2528
. Bumped required libcurl version to 7.29.0. (cmb)
2629

ext/bz2/bz2_filter.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ static php_stream_filter_status_t php_bz2_decompress_filter(
123123
}
124124
} else if (status != BZ_OK) {
125125
/* Something bad happened */
126+
php_error_docref(NULL, E_NOTICE, "bzip2 decompression failed");
126127
php_stream_bucket_delref(bucket);
127128
return PSFS_ERR_FATAL;
128129
}

ext/bz2/tests/bug71263.phpt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
--TEST--
2-
Bug #71263: fread() does not detects decoding errors from filter bzip2.decompress
2+
Bug #71263: fread() does not report bzip2.decompress errors
33
--SKIPIF--
44
<?php if (!extension_loaded("bz2")) print "skip bz2 extension not loaded"; ?>
55
--FILE--
66
<?php
77

8-
// Should notices be generated?
9-
108
function test($case) {
119
$plain = "The quick brown fox jumps over the lazy dog.";
1210
$fn = "bug71263.bz2";
@@ -46,10 +44,14 @@ test(1);
4644
test(2);
4745
test(3);
4846
?>
49-
--EXPECT--
47+
--EXPECTF--
5048
Compressed len = 81
49+
50+
Notice: fread(): bzip2 decompression failed in %s on line %d
5151
read: bool(false)
5252
Compressed len = 81
5353
read: string(0) ""
5454
Compressed len = 81
55+
56+
Notice: fread(): bzip2 decompression failed in %s on line %d
5557
read: bool(false)

0 commit comments

Comments
 (0)