Bug #54798 [NEW]: Segfault when CURLOPT_STDERR file pointer is closed before calling curl_exec
| From: | shein@php.net | Date: | Tue, 17 May 2011 14:25:35 +0000 |
| Subject: | Bug #54798 [NEW]: Segfault when CURLOPT_STDERR file pointer is closed before calling curl_exec | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-160788@lists.php.net to get a copy of this message | ||
From:
Operating system: Ubuntu Linux 11.04 x86
PHP version: trunk-SVN-2011-05-17 (SVN)
Package: cURL related
Bug Type: Bug
Bug description:Segfault when CURLOPT_STDERR file pointer is closed before calling curl_exec
Description:
------------
Related to http://bugs.php.net/bug.php?id=48203
Curl crashes when CURLOPT_STDERR file pointer is closed before calling
curl_exec(), i.e.
$fp = fopen(dirname(__FILE__) . '/bug48203.tmp', 'w');
$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_STDERR, $fp);
curl_setopt($ch, CURLOPT_URL, getenv("PHP_CURL_HTTP_REMOTE_SERVER"));
fclose($fp); // <-- premature close of $fp caused a crash!
curl_exec($ch); // segfault
Error is reproduced on latest svn php5.3, php5.4 and trunk
Fix is also attached here.
Test script:
---------------
Full test script is available here:
http://svn.php.net/viewvc/php/php-src/trunk/ext/curl/tests/bug48203.phpt?view=markup
Expected result:
----------------
No segfault, see test script
Actual result:
--------------
Segfault
--
Edit bug report at http://bugs.php.net/bug.php?id=54798&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54798&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54798&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54798&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=54798&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54798&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=54798&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=54798&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=54798&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=54798&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=54798&r=support
Expected behavior: http://bugs.php.net/fix.php?id=54798&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=54798&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=54798&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=54798&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54798&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=54798&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=54798&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=54798&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=54798&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=54798&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=54798&r=mysqlcfg