From 35e88eed3d4252df6117849253ed6a342ea6e506 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 12 Feb 2018 19:38:44 +0900 Subject: [PATCH] [Modify] Add a check for the Content-Length header --- websocket-sharp/Net/HttpListenerRequest.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/websocket-sharp/Net/HttpListenerRequest.cs b/websocket-sharp/Net/HttpListenerRequest.cs index de473f01..4f0628a7 100644 --- a/websocket-sharp/Net/HttpListenerRequest.cs +++ b/websocket-sharp/Net/HttpListenerRequest.cs @@ -63,6 +63,7 @@ namespace WebSocketSharp.Net private HttpConnection _connection; private Encoding _contentEncoding; private long _contentLength; + private bool _contentLengthSet; private HttpListenerContext _context; private CookieCollection _cookies; private WebHeaderCollection _headers; @@ -612,6 +613,11 @@ namespace WebSocketSharp.Net var lower = name.ToLower (CultureInfo.InvariantCulture); if (lower == "content-length") { + if (_contentLengthSet) { + _context.ErrorMessage = "Invalid Content-Length header"; + return; + } + long len; if (!Int64.TryParse (val, out len)) { _context.ErrorMessage = "Invalid Content-Length header"; @@ -624,6 +630,8 @@ namespace WebSocketSharp.Net } _contentLength = len; + _contentLengthSet = true; + return; } }