soywiz/csharputils — Issue #3: FastCGI long Param error
Author: mrebello
Created: 2011-12-16 18:33:35+00:00
State: open

I found an error in FastcgiPacketReader.cs in function ReadVariableInt.
The rotation of bit was to wrong direction and then 0xFF should by 0x7F (cut the eight bit).
I think that correct code is:

static public int ReadVariableInt(Stream Stream)
{
int Byte = Stream.ReadByte();
if (Byte < 0) throw (new Exception("Can't ready more bytes"));
if ((Byte & 0x80) != 0)
{
return (
(Byte & 0x7F ) << 24 |
Stream.ReadByte() << 16 |
Stream.ReadByte() << 8 |
Stream.ReadByte()
);
}
else
{
return Byte;
}
}