Add length constrain in path processing

This commit is contained in:
Troy Dai 2016-09-06 10:54:26 -07:00
parent 35429bd91f
commit 100beaaf94
2 changed files with 10 additions and 1 deletions

View File

@ -183,7 +183,6 @@ namespace Microsoft.Net.Http.Server
internal byte[] GetRawUrlInBytes()
{
if (NativeRequest->pRawUrl != null && NativeRequest->RawUrlLength > 0)
{
var result = new byte[NativeRequest->RawUrlLength];

View File

@ -93,6 +93,11 @@ namespace Microsoft.Net.Http.Server
/// <returns>Length of the matched bytes, 0 if it is not matched.</returns>
private static int FindHttpOrHttps(byte[] raw)
{
if (raw.Length < 7)
{
return 0;
}
if (raw[0] != 'h' && raw[0] != 'H')
{
return 0;
@ -126,6 +131,11 @@ namespace Microsoft.Net.Http.Server
}
else if (raw[4] == 's' || raw[4] == 'S')
{
if (raw.Length < 8)
{
return 0;
}
if (raw[5] != ':' || raw[6] != '/' || raw[7] != '/')
{
return 0;