diff options
author | Yuriy Glukhov <yuriy.glukhov@gmail.com> | 2018-01-11 23:02:42 +0200 |
---|---|---|
committer | Yuriy Glukhov <yuriy.glukhov@gmail.com> | 2018-01-11 23:02:42 +0200 |
commit | cfc0a58417e4b6967fbb334e8d6556dccc1efad3 (patch) | |
tree | bb0de3a3e0ef29d65dcf32f52e3a9d350ba09012 /lib | |
parent | 425f221440cbd453591d0fca9eaf93671d5f6d62 (diff) | |
download | Nim-cfc0a58417e4b6967fbb334e8d6556dccc1efad3.tar.gz |
Fixed crash in ssl httpclient
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/httpclient.nim | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/pure/httpclient.nim b/lib/pure/httpclient.nim index 54a8498fa..aefcff37a 100644 --- a/lib/pure/httpclient.nim +++ b/lib/pure/httpclient.nim @@ -923,8 +923,14 @@ proc parseChunks(client: HttpClient | AsyncHttpClient): Future[void] if chunkSize <= 0: discard await recvFull(client, 2, client.timeout, false) # Skip \c\L break - discard await recvFull(client, chunkSize, client.timeout, true) - discard await recvFull(client, 2, client.timeout, false) # Skip \c\L + var bytesRead = await recvFull(client, chunkSize, client.timeout, true) + if bytesRead != chunkSize: + httpError("Server terminated connection prematurely") + + bytesRead = await recvFull(client, 2, client.timeout, false) # Skip \c\L + if bytesRead != 2: + httpError("Server terminated connection prematurely") + # Trailer headers will only be sent if the request specifies that we want # them: http://tools.ietf.org/html/rfc2616#section-3.6.1 @@ -965,7 +971,7 @@ proc parseBody(client: HttpClient | AsyncHttpClient, if headers.getOrDefault"Connection" == "close" or httpVersion == "1.0": while true: let recvLen = await client.recvFull(4000, client.timeout, true) - if recvLen == 0: + if recvLen != 4000: client.close() break |