Skip to content

Commit

Permalink
Fix #77020: null pointer dereference in imap_mail
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
smalyshev committed Dec 3, 2018
1 parent aabdb71 commit 7edc639
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS
Expand Up @@ -3,6 +3,7 @@ PHP NEWS
?? ??? 2018, PHP 5.6.39

- IMAP:
. Fixed bug #77020 (null pointer dereference in imap_mail). (cmb)
. Fixed bug #77153 (imap_open allows to run arbitrary shell commands via
mailbox parameter). (Stas)

Expand Down
1 change: 0 additions & 1 deletion ext/imap/php_imap.c
Expand Up @@ -4094,7 +4094,6 @@ PHP_FUNCTION(imap_mail)
if (!message_len) {
/* this is not really an error, so it is allowed. */
php_error_docref(NULL TSRMLS_CC, E_WARNING, "No message string in mail command");
message = NULL;
}

if (_php_imap_mail(to, subject, message, headers, cc, bcc, rpath TSRMLS_CC)) {
Expand Down
15 changes: 15 additions & 0 deletions ext/imap/tests/bug77020.phpt
@@ -0,0 +1,15 @@
--TEST--
Bug #77020 (null pointer dereference in imap_mail)
--SKIPIF--
<?php
if (!extension_loaded('imap')) die('skip imap extension not available');
?>
--FILE--
<?php
imap_mail('1', 1, NULL);
?>
===DONE===
--EXPECTF--
Warning: imap_mail(): No message string in mail command in %s on line %d
%s
===DONE===

0 comments on commit 7edc639

Please sign in to comment.