php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67059 String pointer problem in object $_SERVER when using a proxy (buffer overflow)
Submitted: 2014-04-11 12:49 UTC Modified: 2021-08-22 04:22 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: potsky at me dot com Assigned: cmb (profile)
Status: No Feedback Package: Apache2 related
PHP Version: 5.5.11 OS: Mac OS 10.9
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 — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
30 - 4 = ?
Subscribe to this entry?

 
 [2014-04-11 12:49 UTC] potsky at me dot com
Description:
------------
Hi,

when using a proxy server between a client and the PHP server, the $_SERVER['SERVER_NAME'] is not set correctly and I think there is a serious pointer problem.

Echoing $_SERVER['SERVER_NAME'] tells "potskymac.local:5757" but it tells that the string is 11 chars length. This is wrong of course.

Parsing the string char by char returns the name of the internal PHP server dev.musicme instead.

This problem has been teste on 5.5.9 and 5.5.11.

Test script:
---------------
<?php
$a = $_SERVER['SERVER_NAME'];

var_dump( $a );

var_dump( chr( ord( $a[0] ) ) );
var_dump( chr( ord( $a[1] ) ) );
var_dump( chr( ord( $a[2] ) ) );
var_dump( chr( ord( $a[3] ) ) );
...

var_dump( '' . $_SERVER['SERVER_NAME'] );

die();

Expected result:
----------------
On a direct connection, the result is right and is :

string 'potskymac.local' (length=15)
string 'p' (length=1)
string 'o' (length=1)
string 't' (length=1)
string 's' (length=1)
string 'k' (length=1)
string 'y' (length=1)
string 'm' (length=1)
string 'a' (length=1)
string 'c' (length=1)
string '.' (length=1)
string 'l' (length=1)
string 'o' (length=1)
string 'c' (length=1)
string 'a' (length=1)
string 'l' (length=1)

It should be the same when using a proxy.

Actual result:
--------------
When using a proxy, the string is broken with echo, print_r, var_dump, etc... It seems there are 2 pointers for the same string. Just take a look on the cur result, the value is 11 chars length and is my proxy server dev.musicme :

string 'potskymac.local:5757' (length=11)
string 'd' (length=1)
string 'e' (length=1)
string 'v' (length=1)
string '.' (length=1)
string 'm' (length=1)
string 'u' (length=1)
string 's' (length=1)
string 'i' (length=1)
string 'c' (length=1)
string 'm' (length=1)
string 'e' (length=1)

( ! ) Notice: Uninitialized string offset: 11



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-08-09 14:13 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-08-09 14:13 UTC] cmb@php.net
Is this still an issue with any of the actively supported PHP
versions[1]?

[1] <https://www.php.net/supported-versions.php>
 [2021-08-22 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 11:01:27 2024 UTC