From 671b5be6e9d74fec9e94b1ab88d2b2648c540078 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Fri, 27 Sep 2013 23:47:13 +0400 Subject: [PATCH] tls: fix sporadic hang and partial reads Do not decrement size in read loop, its used later, when comparing to `bytesRead`. fix #6270 NOTE: Original patch contributed by @roadrunner2 --- lib/tls.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/tls.js b/lib/tls.js index a758c8e01c0..fe94a5121f3 100644 --- a/lib/tls.js +++ b/lib/tls.js @@ -447,10 +447,9 @@ CryptoStream.prototype._read = function read(size) { var bytesRead = 0, start = this._buffer.offset; do { - var read = this._buffer.use(this.pair.ssl, out, size); + var read = this._buffer.use(this.pair.ssl, out, size - bytesRead); if (read > 0) { bytesRead += read; - size -= read; } // Handle and report errors