diff options
author | Stanislav Malyshev <stas@php.net> | 2018-12-03 02:12:11 -0800 |
---|---|---|
committer | Sara Golemon <pollita@php.net> | 2018-12-04 11:29:51 -0500 |
commit | a5646a9d0052879444260234a4fff92f6b954658 (patch) | |
tree | 3355d79d770adfe95174fd394170e4597ffa4339 | |
parent | 80ea25c28d9139e237fd65c0a0f2aa87385e03e4 (diff) | |
download | php-git-a5646a9d0052879444260234a4fff92f6b954658.tar.gz |
Fix null pointer deref in qprint-encode filter (bug #77231)
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | ext/standard/filters.c | 2 | ||||
-rw-r--r-- | ext/standard/tests/filters/bug77231.phpt | 11 |
3 files changed, 16 insertions, 1 deletions
@@ -13,6 +13,10 @@ PHP NEWS . Fixed bug #77147 (Fixing 60494 ignored ICONV_MIME_DECODE_CONTINUE_ON_ERROR). (cmb) +- Core: + . Fixed bug #77231 (Segfault when using convert.quoted-printable-encode + filter). (Stas) + - IMAP: . Fixed bug #77153 (imap_open allows to run arbitrary shell commands via mailbox parameter). (Stas) diff --git a/ext/standard/filters.c b/ext/standard/filters.c index 7115c534b0..cd92c6e2dc 100644 --- a/ext/standard/filters.c +++ b/ext/standard/filters.c @@ -922,7 +922,7 @@ static php_conv_err_t php_conv_qprint_encode_convert(php_conv_qprint_encode *ins line_ccnt--; CONSUME_CHAR(ps, icnt, lb_ptr, lb_cnt); } else { - if (line_ccnt < 4) { + if (line_ccnt < 4 && inst->lbchars != NULL) { if (ocnt < inst->lbchars_len + 1) { err = PHP_CONV_ERR_TOO_BIG; break; diff --git a/ext/standard/tests/filters/bug77231.phpt b/ext/standard/tests/filters/bug77231.phpt new file mode 100644 index 0000000000..17967ee80f --- /dev/null +++ b/ext/standard/tests/filters/bug77231.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #77231 (Segfault when using convert.quoted-printable-encode filter) +--FILE-- +<?php +var_dump(file(urldecode('php://filter/convert.quoted-printable-encode/resource=data://,%bfAAAAAAAAFAAAAAAAAAAAAAA%ff%ff%ff%ff%ff%ff%ff%ffAAAAAAAAAAAAAAAAAAAAAAAA'))); +?> +--EXPECT-- +array(1) { + [0]=> + string(74) "=BFAAAAAAAAFAAAAAAAAAAAAAA=FF=FF=FF=FF=FF=FF=FF=FFAAAAAAAAAAAAAAAAAAAAAAAA" +}
\ No newline at end of file |