diff options
author | Stanislav Malyshev <stas@php.net> | 2018-12-03 02:12:11 -0800 |
---|---|---|
committer | Sara Golemon <pollita@php.net> | 2018-12-04 10:43:38 -0500 |
commit | 09cb5714734ca98edbe9845cded7578472c782ca (patch) | |
tree | 8de75b0784620cde010901da32970b712475d620 | |
parent | 8852e24a9819319844cd165855e7efb46be3c9c5 (diff) | |
download | php-git-09cb5714734ca98edbe9845cded7578472c782ca.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
@@ -17,6 +17,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 55b5a9df51..03e5e11df8 100644 --- a/ext/standard/filters.c +++ b/ext/standard/filters.c @@ -917,7 +917,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 |