Skip to content

Commit 09cb571

Browse files
smalyshevsgolemon
authored andcommitted
Fix null pointer deref in qprint-encode filter (bug #77231)
1 parent 8852e24 commit 09cb571

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ PHP NEWS
1717
. Fixed bug #77147 (Fixing 60494 ignored ICONV_MIME_DECODE_CONTINUE_ON_ERROR).
1818
(cmb)
1919

20+
- Core:
21+
. Fixed bug #77231 (Segfault when using convert.quoted-printable-encode
22+
filter). (Stas)
23+
2024
- IMAP:
2125
. Fixed bug #77153 (imap_open allows to run arbitrary shell commands via
2226
mailbox parameter). (Stas)

ext/standard/filters.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ static php_conv_err_t php_conv_qprint_encode_convert(php_conv_qprint_encode *ins
917917
line_ccnt--;
918918
CONSUME_CHAR(ps, icnt, lb_ptr, lb_cnt);
919919
} else {
920-
if (line_ccnt < 4) {
920+
if (line_ccnt < 4 && inst->lbchars != NULL) {
921921
if (ocnt < inst->lbchars_len + 1) {
922922
err = PHP_CONV_ERR_TOO_BIG;
923923
break;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
Bug #77231 (Segfault when using convert.quoted-printable-encode filter)
3+
--FILE--
4+
<?php
5+
var_dump(file(urldecode('php://filter/convert.quoted-printable-encode/resource=data://,%bfAAAAAAAAFAAAAAAAAAAAAAA%ff%ff%ff%ff%ff%ff%ff%ffAAAAAAAAAAAAAAAAAAAAAAAA')));
6+
?>
7+
--EXPECT--
8+
array(1) {
9+
[0]=>
10+
string(74) "=BFAAAAAAAAFAAAAAAAAAAAAAA=FF=FF=FF=FF=FF=FF=FF=FFAAAAAAAAAAAAAAAAAAAAAAAA"
11+
}

0 commit comments

Comments
 (0)