Skip to content

Commit dc75e05

Browse files
committed
fix null pointer dereference in php_mail_detect_multiple_crlf via error_log
1 parent cb63e4f commit dc75e05

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

ext/standard/basic_functions.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,9 @@ PHPAPI zend_result _php_error_log(int opt_err, const zend_string *message, const
13531353
switch (opt_err)
13541354
{
13551355
case 1: /*send an email */
1356-
if (!php_mail(ZSTR_VAL(opt), "PHP error_log message", ZSTR_VAL(message), ZSTR_VAL(headers), NULL)) {
1356+
const char *to = opt ? ZSTR_VAL(opt) : NULL;
1357+
const char *hdrs = headers ? ZSTR_VAL(headers) : NULL;
1358+
if (!php_mail(to, "PHP error_log message", ZSTR_VAL(message), hdrs, NULL)) {
13571359
return FAILURE;
13581360
}
13591361
break;

tests/basic/gh20858.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--TEST--
2+
GH-20858 Null pointer dereference in php_mail_detect_multiple_crlf via error_log
3+
--FILE--
4+
<?php
5+
error_log(0, 1, null);
6+
?>
7+
--EXPECTF--
8+
sendmail: fatal: %r[^()]+%r(%d): No recipient addresses found in message header

0 commit comments

Comments
 (0)