Skip to content

Commit 7edc639

Browse files
committed
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).
1 parent aabdb71 commit 7edc639

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ PHP NEWS
33
?? ??? 2018, PHP 5.6.39
44

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

ext/imap/php_imap.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4094,7 +4094,6 @@ PHP_FUNCTION(imap_mail)
40944094
if (!message_len) {
40954095
/* this is not really an error, so it is allowed. */
40964096
php_error_docref(NULL TSRMLS_CC, E_WARNING, "No message string in mail command");
4097-
message = NULL;
40984097
}
40994098

41004099
if (_php_imap_mail(to, subject, message, headers, cc, bcc, rpath TSRMLS_CC)) {

ext/imap/tests/bug77020.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #77020 (null pointer dereference in imap_mail)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('imap')) die('skip imap extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
imap_mail('1', 1, NULL);
10+
?>
11+
===DONE===
12+
--EXPECTF--
13+
Warning: imap_mail(): No message string in mail command in %s on line %d
14+
%s
15+
===DONE===

0 commit comments

Comments
 (0)