php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30475 Curl curl_getinfo()
Submitted: 2004-10-18 23:02 UTC Modified: 2004-10-19 00:43 UTC
From: mikeb at xamo dot com Assigned:
Status: Closed Package: cURL related
PHP Version: 5.0.2 OS: FreeBSD 4.8
Private report: No CVE-ID: None
 [2004-10-18 23:02 UTC] mikeb at xamo dot com
Description:
------------
When requesting the CURLINFO_CONTENT_TYPE using curl_getinfo(), if there is an error (such as connection error) or missing header for any reason, running the function using specifically curl_getinfo($fd,CURLINFO_CONTENT_TYPE) will cause a PHP core dump.

The problem seems to be that the function does not check for the instance of the Content-Type: header before it tries to parse it.

Temporary workaround is simply not using the function, and parsing for the data yourself.

Reproduce code:
---------------
<?
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,"http://sell.yahoo.com/");
curl_setopt($ch,CURLOPT_HEADER,1);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$contents=curl_exec($ch);

// the following line will cause a core dump
//    as sell.yahoo.com does not return an appropriate Content-Type header. Also happens on connect errors.
$content_type=curl_getinfo($ch,CURLINFO_CONTENT_TYPE);


curl_close($ch);
?>

Expected result:
----------------
Should return content-type in the HTTP Header (if it exists, or false/empty string if it doesnt exist)

Actual result:
--------------
PHP Core Dump.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-10-19 00:43 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 07:01:29 2024 UTC