summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-10-10 19:17:59 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2020-10-10 19:18:14 +0200
commitb2b9e2e87e780d814ffc6ceeaf1b546a14e76799 (patch)
tree74bd9112cd48f30b89cd9947f23529dfe0a0b24f
parent82e5752b0bae23410d79ed681c96f48993d1ecb4 (diff)
parent8bee0fbd37c8eee0a17abe4a0afd69ad9ac7105a (diff)
downloadphp-git-b2b9e2e87e780d814ffc6ceeaf1b546a14e76799.tar.gz
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #80213: imap_mail_compose() segfaults on certain $bodies
-rw-r--r--NEWS3
-rw-r--r--ext/imap/php_imap.c4
-rw-r--r--ext/imap/tests/bug80213.phpt21
3 files changed, 28 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index d4e7e6e93d..7cd80de852 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,9 @@ PHP NEWS
- Calendar:
. Fixed bug #80185 (jdtounix() fails after 2037). (cmb)
+- IMAP:
+ . Fixed bug #80213 (imap_mail_compose() segfaults on certain $bodies). (cmb)
+
- MySQLnd:
. Fixed bug #80115 (mysqlnd.debug doesn't recognize absolute paths with
slashes). (cmb)
diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c
index e6ea7906f7..3e708796f0 100644
--- a/ext/imap/php_imap.c
+++ b/ext/imap/php_imap.c
@@ -3657,6 +3657,7 @@ PHP_FUNCTION(imap_mail_compose)
if(Z_TYPE_P(pvalue) == IS_ARRAY) {
disp_param = tmp_param = NULL;
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(pvalue), key, disp_data) {
+ if (key == NULL) continue;
disp_param = mail_newbody_parameter();
disp_param->attribute = cpystr(ZSTR_VAL(key));
convert_to_string_ex(disp_data);
@@ -3689,6 +3690,7 @@ PHP_FUNCTION(imap_mail_compose)
if (Z_TYPE_P(pvalue) == IS_ARRAY) {
disp_param = tmp_param = NULL;
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(pvalue), key, disp_data) {
+ if (key == NULL) continue;
disp_param = mail_newbody_parameter();
disp_param->attribute = cpystr(ZSTR_VAL(key));
convert_to_string_ex(disp_data);
@@ -3757,6 +3759,7 @@ PHP_FUNCTION(imap_mail_compose)
if (Z_TYPE_P(pvalue) == IS_ARRAY) {
disp_param = tmp_param = NULL;
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(pvalue), key, disp_data) {
+ if (key == NULL) continue;
disp_param = mail_newbody_parameter();
disp_param->attribute = cpystr(ZSTR_VAL(key));
convert_to_string_ex(disp_data);
@@ -3789,6 +3792,7 @@ PHP_FUNCTION(imap_mail_compose)
if (Z_TYPE_P(pvalue) == IS_ARRAY) {
disp_param = tmp_param = NULL;
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(pvalue), key, disp_data) {
+ if (key == NULL) continue;
disp_param = mail_newbody_parameter();
disp_param->attribute = cpystr(ZSTR_VAL(key));
convert_to_string_ex(disp_data);
diff --git a/ext/imap/tests/bug80213.phpt b/ext/imap/tests/bug80213.phpt
new file mode 100644
index 0000000000..9a7961df77
--- /dev/null
+++ b/ext/imap/tests/bug80213.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Bug #80213 (imap_mail_compose() segfaults on certain $bodies)
+--SKIPIF--
+<?php
+if (!extension_loaded('imap')) die('skip imap extension not available');
+?>
+--FILE--
+<?php
+$envelope = [];
+$body = [[
+ 'type.parameters' => ['param'],
+ 'disposition' => ['disp'],
+], [
+ 'type.parameters' => ['param'],
+ 'disposition' => ['disp'],
+]];
+imap_mail_compose($envelope, $body);
+echo "done\n";
+?>
+--EXPECT--
+done