Bug #67059 [NEW]: String pointer problem in object $_SERVER when using a proxy (buffer overflow)
| From: | potsky at me dot com | Date: | Fri, 11 Apr 2014 12:49:24 +0000 |
| Subject: | Bug #67059 [NEW]: String pointer problem in object $_SERVER when using a proxy (buffer overflow) | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-185179@lists.php.net to get a copy of this message | ||
From: potsky at me dot com
Operating system: Mac OS 10.9
PHP version: 5.5.11
Package: Apache2 related
Bug Type: Bug
Bug description:String pointer problem in object $_SERVER when using a proxy (buffer overflow)
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
--
Edit bug report at https://bugs.php.net/bug.php?id=67059&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=67059&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=67059&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=67059&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=67059&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=67059&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=67059&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=67059&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=67059&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=67059&r=support
Expected behavior: https://bugs.php.net/fix.php?id=67059&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=67059&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=67059&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=67059&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=67059&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=67059&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=67059&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=67059&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=67059&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=67059&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=67059&r=mysqlcfg