php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80215 imap_mail_compose() may modify by-val parameters
Submitted: 2020-10-10 12:39 UTC Modified: 2020-10-10 12:39 UTC
From: cmb@php.net Assigned: cmb (profile)
Status: Closed Package: IMAP related
PHP Version: 7.3Git-2020-10-10 (Git) OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cmb@php.net
New email:
PHP Version: OS:

 

 [2020-10-10 12:39 UTC] cmb@php.net
Description:
------------
imap_mail_compose() accepts two possibly nested arrays of strings,
and due to type juggling, may actually convert the elements to
string.


Test script:
---------------
<?php
$envelope = [
    "from" => 1,
    "to" => 2,
    "custom_headers" => [3],
];
$body = [[
    "contents.data" => 4,
    "type.parameters" => ['foo' => 5],
    "disposition" => ['bar' => 6],
], [
    "contents.data" => 7,
    "type.parameters" => ['foo' => 8],
    "disposition" => ['bar' => 9],
]];
imap_mail_compose($envelope, $body);
var_dump($envelope, $body);
?>


Expected result:
----------------
array(3) {
  ["from"]=>
  int(1)
  ["to"]=>
  int(2)
  ["custom_headers"]=>
  array(1) {
    [0]=>
    int(3)
  }
}
array(2) {
  [0]=>
  array(3) {
    ["contents.data"]=>
    int(4)
    ["type.parameters"]=>
    array(1) {
      ["foo"]=>
      int(5)
    }
    ["disposition"]=>
    array(1) {
      ["bar"]=>
      int(6)
    }
  }
  [1]=>
  array(3) {
    ["contents.data"]=>
    int(7)
    ["type.parameters"]=>
    array(1) {
      ["foo"]=>
      int(8)
    }
    ["disposition"]=>
    array(1) {
      ["bar"]=>
      int(9)
    }
  }
}


Actual result:
--------------
array(3) {
  ["from"]=>
  string(1) "1"
  ["to"]=>
  string(1) "2"
  ["custom_headers"]=>
  array(1) {
    [0]=>
    string(1) "3"
  }
}
array(2) {
  [0]=>
  array(3) {
    ["contents.data"]=>
    string(1) "4"
    ["type.parameters"]=>
    array(1) {
      ["foo"]=>
      string(1) "5"
    }
    ["disposition"]=>
    array(1) {
      ["bar"]=>
      string(1) "6"
    }
  }
  [1]=>
  array(3) {
    ["contents.data"]=>
    string(1) "7"
    ["type.parameters"]=>
    array(1) {
      ["foo"]=>
      string(1) "8"
    }
    ["disposition"]=>
    array(1) {
      ["bar"]=>
      string(1) "9"
    }
  }
}


Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-10-10 12:39 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2020-10-10 15:31 UTC] cmb@php.net
The following pull request has been associated:

Patch Name: Fix #80215: imap_mail_compose() may modify by-val parameters
On GitHub:  https://github.com/php/php-src/pull/6316
Patch:      https://github.com/php/php-src/pull/6316.patch
 [2020-10-10 21:29 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=62a2387a8dc262ae75a6575fabddd6170b4bdb07
Log: Fix #80215: imap_mail_compose() may modify by-val parameters
 [2020-10-10 21:29 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 12:01:27 2024 UTC