Fix for issue #46

This commit is contained in:
sta 2014-05-15 12:31:20 +09:00
parent e20c3df551
commit cae324a936

View File

@ -101,10 +101,18 @@ namespace WebSocketSharp
private static byte [] readHandshakeEntityBody (Stream stream, string length)
{
var len = Int64.Parse (length);
long len;
if (!Int64.TryParse (length, out len))
throw new ArgumentException ("Cannot be parsed.", "length");
if (len < 0)
throw new ArgumentOutOfRangeException ("length", "Less than zero.");
return len > 1024
? stream.ReadBytes (len, 1024)
: stream.ReadBytes ((int) len);
: len > 0
? stream.ReadBytes ((int) len)
: null;
}
private static string [] readHandshakeHeaders (Stream stream)