Bug #79741 [NEW]: segfault: curl_setopt/CURLOPT_POSTFIELDS using toStringable
| From: | sjon@php.net | Date: | Fri, 26 Jun 2020 08:45:51 +0000 |
| Subject: | Bug #79741 [NEW]: segfault: curl_setopt/CURLOPT_POSTFIELDS using toStringable | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-227683@lists.php.net to get a copy of this message | ||
From: sjon
Operating system: archLinux
PHP version: 7.4.7
Package: cURL related
Bug Type: Bug
Bug description:segfault: curl_setopt/CURLOPT_POSTFIELDS using toStringable
Description:
------------
#0 0x00007f9e8c4ba355 raise (libc.so.6 + 0x3c355)
#1 0x00007f9e8c4a3853 abort (libc.so.6 + 0x25853)
#2 0x00007f9e8c4a3727 __assert_fail_base.cold (libc.so.6 + 0x25727)
#3 0x00007f9e8c4b2936 __assert_fail (libc.so.6 + 0x34936)
#4 0x000055e572bcd0d2 __zval_get_string_func (php + 0x64f0d2)
#5 0x000055e572bcd106 zval_get_string_func (php + 0x64f106)
#6 0x00007f9e8a479635 zval_get_tmp_string (curl.so + 0x4635)
#7 0x00007f9e8a482503 build_mime_structure_from_hash (curl.so +
0xd503)
#8 0x00007f9e8a483dfa _php_curl_setopt (curl.so + 0xedfa)
#9 0x00007f9e8a484c4b zif_curl_setopt (curl.so + 0xfc4b)
#10 0x000055e572c4fd71 ZEND_DO_ICALL_SPEC_RETVAL_UNUSED_HANDLER (php +
0x6d1d71)
#11 0x000055e572cb64bc execute_ex (php + 0x7384bc)
#12 0x000055e572cba613 zend_execute (php + 0x73c613)
#13 0x000055e572bdc0e9 zend_execute_scripts (php + 0x65e0e9)
#14 0x000055e572b39fc0 php_execute_script (php + 0x5bbfc0)
#15 0x000055e572cbd1c1 do_cli (php + 0x73f1c1)
#16 0x000055e572cbe3c1 main (php + 0x7403c1)
#17 0x00007f9e8c4a5002 __libc_start_main (libc.so.6 + 0x27002)
#18 0x000055e57277e6ae _start (php + 0x2006ae)
Test script:
---------------
<?php
class x
{
private $_body;
public function __construct(SimpleXMLElement $body)
{
$this->_body = $body;
}
public function __toString()
{
return $this->_body->asXML();
}
}
$body = new x(simplexml_load_string('<?xml version="1.0"
encoding="UTF-8"?>
<Test>
<Id>123</Id>
</Test>'));
$ch = curl_init();
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
Expected result:
----------------
no segfault - which can be achieved by manually casting to string first
eg. curl_setopt($ch, CURLOPT_POSTFIELDS, (string)$body);
Actual result:
--------------
segfault
--
Edit bug report at https://bugs.php.net/bug.php?id=79741&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79741&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79741&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79741&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79741&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79741&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79741&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79741&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79741&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79741&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79741&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79741&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79741&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79741&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79741&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79741&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79741&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79741&r=mysqlcfg