php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69759 \http\Url() leaks memory for long urls.
Submitted: 2015-06-05 09:25 UTC Modified: 2015-06-16 07:13 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: mail at ankr dot dk Assigned:
Status: Duplicate Package: pecl_http (PECL)
PHP Version: 5.6.9 OS: Debian 3.2.65-1+deb7u2 x86_64
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.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mail at ankr dot dk
New email:
PHP Version: OS:

 

 [2015-06-05 09:25 UTC] mail at ankr dot dk
Description:
------------
Using \http\Url() to construct a URL from fragments leaks memory if the constructed url gets too big.
In the attached test example the query part of the url will disappear and replaced with random memory data.
It appears that it's not only happening when query string gets too long, but rather when the total url length exceeds a certain limit.

Test script:
---------------
<?php
// leak.php
// https://gist.github.com/ankr/a5645212e8e1dc9979ef

$url = 'http://aaaaaaaaaaaaaaaaaaaa.aaa/aaaaaa';   // This length will work as expected
$url = 'http://aaaaaaaaaaaaaaaaaaaa.aaa/aaaaaaa';  // This length will cause Url() to ignore the 'query' part
$url = 'http://aaaaaaaaaaaaaaaaaaaa.aaa/aaaaaaaa'; // This length will cause Url() to leak

$parsed = parse_url($url);
$parsed['query'] = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';

var_dump((new \http\Url($parsed))->toString());

Actual result:
--------------
$ php leak.php
string(47) "http://aaaaaaaaaaaaaaaaaaaa.aaa/aaaaaaaa?H@��V"

$ php leak.php
string(47) "http://aaaaaaaaaaaaaaaaaaaa.aaa/aaaaaaaa?H��}?"

$ php leak.php
string(47) "http://aaaaaaaaaaaaaaaaaaaa.aaa/aaaaaaaa?H���G"

etc.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-16 07:13 UTC] mike@php.net
-Status: Open +Status: Duplicate
 [2015-06-16 07:13 UTC] mike@php.net
With which version of pecl_http do you experience this behavior?
This should be fixed since 2.2.1

See bug #69000 and commit 6a206380
 [2015-06-25 09:29 UTC] mail at ankr dot dk
You are right. I was using 2.2.0 and problem went away after upgrade. Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 27 14:01:30 2024 UTC