php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59099 http_build_cookie() exhausts memory if cookie value is NULL
Submitted: 2010-03-04 09:26 UTC Modified: 2010-04-27 09:43 UTC
From: justin dot forest at gmail dot com Assigned: mike (profile)
Status: Closed Package: pecl_http (PECL)
PHP Version: 5.3.1 OS: Ubuntu Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
30 + 20 = ?
Subscribe to this entry?

 
 [2010-03-04 09:26 UTC] justin dot forest at gmail dot com
Description:
------------
If cookie value is NULL, http_build_cookies() tries to 
allocate too much memory 
for some reason.

HTTP extension version is 1.6.6. I can reproduce this with 
PHP versions 5.2.8 and 
5.3.1 on Ubuntu, but not in 5.2.12 on FreeBSD.

Passing cookie value through strval() helps.

Reproduce code:
---------------
var_dump(http_build_cookie(array(
  'cookies' => array(
    'empty' => null,
    ),
)));

Expected result:
----------------
$ php -f test-cookies.php 
string(8) "empty=; "

Actual result:
--------------
$ php -f test-cookies.php 

Fatal error: Allowed memory size of 33554432 bytes exhausted 
(tried to allocate 
441559261 bytes) in .../test-cookies.php on line 7

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-27 09:43 UTC] mike@php.net
This bug has been fixed in SVN.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 12:01:28 2024 UTC