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: -
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:
Status: Open 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:
5 + 8 = ?
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

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Nov 15 12:01:34 2019 UTC