From 3329e30a0c631753980757045ddfcc7b356a34a2 Mon Sep 17 00:00:00 2001 Date: Wed, 4 Dec 2019 17:50:56 +0800 Subject: Fix #77020: null pointer dereference in imap_mail If an empty $message is passed to imap_mail(), we must not set message to NULL, since _php_imap_mail() is not supposed to handle NULL pointers (opposed to pointers to NUL). --- ext/imap/php_imap.c | 1 - ext/imap/tests/bug77020.phpt | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 php-7.2.10/ext/imap/tests/bug77020.phpt diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c index e1adcf22..56126a0c 100644 --- a/ext/imap/php_imap.c +++ b/ext/imap/php_imap.c @@ -4106,7 +4106,6 @@ PHP_FUNCTION(imap_mail) if (!ZSTR_LEN(message)) { /* this is not really an error, so it is allowed. */ php_error_docref(NULL, E_WARNING, "No message string in mail command"); - message = NULL; } if (_php_imap_mail(ZSTR_VAL(to), ZSTR_VAL(subject), ZSTR_VAL(message), headers?ZSTR_VAL(headers):NULL, cc?ZSTR_VAL(cc):NULL, diff --git a/ext/imap/tests/bug77020.phpt b/ext/imap/tests/bug77020.phpt new file mode 100644 index 00000000..76386a09 --- /dev/null +++ b/ext/imap/tests/bug77020.phpt @@ -0,0 +1,15 @@ + --TEST-- +Bug #77020 (null pointer dereference in imap_mail) +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: imap_mail(): No message string in mail command in %s on line %d +%s +===DONE=== -- 2.19.1