Bug #66479 [NEW]: Wrong response to FCGI_GET_VALUES
From: miloslav dot hula at gmail dot com
Operating system:
PHP version: Irrelevant
Package: CGI/CLI related
Bug Type: Bug
Bug description:Wrong response to FCGI_GET_VALUES
Description:
------------
When querying PHP over FastCGI protocol, I receive a too long response.
Moreover, only one value is returned even more were requested.
http://www.fastcgi.com/devkit/doc/fcgi-spec.html#S4.1
Test script:
---------------
# Let listen PHP as FastCGI on port 9000
php-cgi -b localhost:9000
# Build packt
# Packet content is Name-Value packed FCGI_MAX_CONNS=''
$content = "\x0e\x00FCGI_MAX_CONNS";
$packet = pack('CCnnCC',
1, # Version = FCGI_CGI_VERSION
9, # Type = FCGI_GET_VALUES
0, # Request ID = FCGI_NULL_REQUEST_ID
strlen($content), # Content length
0, # Padding length
0 # Reserved
) . $content;
# Connect to FastCGI
$socket = fsockopen('localhost', 9000);
fwrite($socket, $packet);
$header = (object) unpack(
'Cversion/Ctype/nid/ncontentLength/CpaddingLength/Creserved',
fread($socket, 8) # FCGI_HEADER_LEN
);
assert($header->version === 1); # Version = FCGI_CGI_VERSION
assert($header->type === 10); # Type = GET_VALUES_RESULT
assert($header->id === 0); # Request ID = FCGI_NULL_REQUEST_ID
var_dump($header->contentLength); # I get int(65520)
$raw = fread($socket, $header->contentLength);
var_dump($raw);
# string(...)
"\016\002FCGI_MAX_CONNS10\016\002FCGI_MAX_CONNS10\016\002FCGI_MAX_CONNS10...."
# So reply is too long
# Next problem:
# FastCGI specification allows receive more then one value, but reply
contains always only one, the last one requested.
# Try code above with:
$content = "\x0e\x00FCGI_MAX_CONNS"
. "\xd\x00FCGI_MAX_REQS"
. "\xf\x00FCGI_MPXS_CONNS";
Expected result:
----------------
Reply should contain a Name-Value pair exactly once for each requested.
Actual result:
--------------
Reply is too long, Name-Value pair is repeatedy concatenated, only one
Name-Value pair is replied (the last one) even more requested.
--
Edit bug report at https://bugs.php.net/bug.php?id=66479&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66479&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66479&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66479&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=66479&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=66479&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=66479&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=66479&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=66479&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=66479&r=support
Expected behavior: https://bugs.php.net/fix.php?id=66479&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=66479&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=66479&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=66479&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66479&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=66479&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=66479&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=66479&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66479&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=66479&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=66479&r=mysqlcfg
Thread (2 messages)
- miloslav dot hula at gmail dot com