tls_legacy: do not read on OpenSSL's stack
authorFedor Indutny <fedor@indutny.com>
Wed, 6 Jan 2016 03:42:32 +0000 (22:42 -0500)
committerMyles Borins <mborins@us.ibm.com>
Mon, 15 Feb 2016 19:30:23 +0000 (11:30 -0800)
Do not attempt to read data from the socket whilst on OpenSSL's stack,
weird things may happen, and this is most likely going to result in some
kind of error.

PR-URL: https://github.com/nodejs/node/pull/4624
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
lib/_tls_legacy.js

index 159d60e9ae1011169e8bcac36c812493703a0ef6..3471ccb2d03b58b9bf53928319d8a8ed4e9e9af8 100644 (file)
@@ -614,13 +614,15 @@ function onclienthello(hello) {
 
     if (err) return self.socket.destroy(err);
 
-    self.ssl.loadSession(session);
-    self.ssl.endParser();
+    setImmediate(function() {
+      self.ssl.loadSession(session);
+      self.ssl.endParser();
 
-    // Cycle data
-    self._resumingSession = false;
-    self.cleartext.read(0);
-    self.encrypted.read(0);
+      // Cycle data
+      self._resumingSession = false;
+      self.cleartext.read(0);
+      self.encrypted.read(0);
+    });
   }
 
   if (hello.sessionId.length <= 0 ||