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
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: potsky at me dot com
New email:
PHP Version: OS:

 

 [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 Aug 23 04:01:26 2019 UTC