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
 [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

Pull Requests

Pull requests:

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: Thu Nov 21 14:01:29 2024 UTC