php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69849 Broken output of apache_request_headers
Submitted: 2015-06-16 10:52 UTC Modified: 2015-06-16 14:12 UTC
From: kontakt at kukulich dot cz Assigned: kalle (profile)
Status: Closed Package: *Web Server problem
PHP Version: 7.0.0alpha1 OS: Windows7
Private report: No CVE-ID: None
 [2015-06-16 10:52 UTC] kontakt at kukulich dot cz
Description:
------------
There is a bad character at the end of every key of the apache_request_headers output.

Test script:
---------------
<?php

header('Content-Type: text/plain');
var_dump(apache_request_headers());


Expected result:
----------------
array(8) {
  ["Connection"]=>
  string(10) "keep-alive"
  ["Accept-Encoding"]=>
  string(13) "gzip, deflate"
  ["Accept-Language"]=>
  string(23) "cs,en-US;q=0.7,en;q=0.3"
  ["Accept"]=>
  string(63) "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
  ["User-Agent"]=>
  string(72) "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0"
  ["Host"]=>
  string(9) "localhost:81"
  ["Content-Length"]=>
  string(0) ""
  ["Content-Type"]=>
  string(0) ""
}

Actual result:
--------------
array(8) {
  ["Connection�"]=>
  string(10) "keep-alive"
  ["Accept-Encoding�"]=>
  string(13) "gzip, deflate"
  ["Accept-Language�"]=>
  string(23) "cs,en-US;q=0.7,en;q=0.3"
  ["Accept�"]=>
  string(63) "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
  ["User-Agent�"]=>
  string(72) "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0"
  ["Host�"]=>
  string(12) "localhost:81"
  ["Content-Length�"]=>
  string(0) ""
  ["Content-Type�"]=>
  string(0) ""
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-16 11:22 UTC] cmb@php.net
-Status: Open +Status: Feedback
 [2015-06-16 11:22 UTC] cmb@php.net
I can't reproduce this behavior with the built-in webserver. Which
Server API do you use (see phpinfo)?
 [2015-06-16 11:24 UTC] kontakt at kukulich dot cz
Nginx/1.9.1 + PHP-FPM
 [2015-06-16 11:43 UTC] cmb@php.net
-Status: Feedback +Status: Open
 [2015-06-16 12:42 UTC] laruence@php.net
I don't remember we have apache_request_headers in FPM SAPI... are you meaing cgi?
 [2015-06-16 12:51 UTC] kontakt at kukulich dot cz
Yes, you're right, it's CGI (php-cgi.exe).
 [2015-06-16 12:59 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2015-06-16 12:59 UTC] cmb@php.net
I can confirm the issue for php-cgi. It seems the problem is in
<http://lxr.php.net/xref/PHP_TRUNK/sapi/cgi/cgi_main.c#1553>,
where var_len+1 is passed to add_assoc_stringl_ex().
 [2015-06-16 13:02 UTC] cmb@php.net
The "bad characters" are null bytes, btw.
 [2015-06-16 13:11 UTC] laruence@php.net
-Assigned To: +Assigned To: cmb
 [2015-06-16 13:11 UTC] laruence@php.net
@cmb could you please commit the fix? thanks
 [2015-06-16 14:12 UTC] kalle@php.net
-Status: Verified +Status: Closed -Assigned To: cmb +Assigned To: kalle
 [2015-06-16 14:12 UTC] kalle@php.net
The fix for this bug has been committed.

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/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2015-06-16 14:12 UTC] kalle@php.net
Automatic comment on behalf of kalle
Revision: http://git.php.net/?p=php-src.git;a=commit;h=444526828170b81fd771302714297ca679e15278
Log: Fixed bug #69849 (Broken output of apache_request_headers)
 [2015-06-23 18:04 UTC] ab@php.net
Automatic comment on behalf of kalle
Revision: http://git.php.net/?p=php-src.git;a=commit;h=444526828170b81fd771302714297ca679e15278
Log: Fixed bug #69849 (Broken output of apache_request_headers)
 [2016-07-20 11:38 UTC] davey@php.net
Automatic comment on behalf of kalle
Revision: http://git.php.net/?p=php-src.git;a=commit;h=444526828170b81fd771302714297ca679e15278
Log: Fixed bug #69849 (Broken output of apache_request_headers)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 11:01:29 2024 UTC