| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0180fc5 commit 3da003c
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -689,7 +689,9 @@ TLSSocket.prototype._init = function(socket, wrap) { | |||
| 689 | 689 | if (event !== 'keylog') | |
| 690 | 690 | return; | |
| 691 | 691 | ||
| 692 | - ssl.enableKeylogCallback(); | ||
| 692 | + // Guard against enableKeylogCallback after destroy | ||
| 693 | + if (!this._handle) return; | ||
| 694 | + this._handle.enableKeylogCallback(); | ||
| 693 | 695 | ||
| 694 | 696 | // Remove this listener since it's no longer needed. | |
| 695 | 697 | this.removeListener('newListener', keylogNewListener); | |
@@ -733,7 +735,9 @@ TLSSocket.prototype._init = function(socket, wrap) { | |||
| 733 | 735 | if (event !== 'session') | |
| 734 | 736 | return; | |
| 735 | 737 | ||
| 736 | - ssl.enableSessionCallbacks(); | ||
| 738 | + // Guard against enableSessionCallbacks after destroy | ||
| 739 | + if (!this._handle) return; | ||
| 740 | + this._handle.enableSessionCallbacks(); | ||
| 737 | 741 | ||
| 738 | 742 | // Remove this listener since it's no longer needed. | |
| 739 | 743 | this.removeListener('newListener', newListener); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,22 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + if (!common.hasCrypto) | ||
| 4 | + common.skip('missing crypto'); | ||
| 5 | + | ||
| 6 | + // This test ensures that Node.js doesn't incur a segfault while | ||
| 7 | + // adding session or keylog listeners after destroy. | ||
| 8 | + // https://github.com/nodejs/node/issues/38133 | ||
| 9 | + // https://github.com/nodejs/node/issues/38135 | ||
| 10 | + | ||
| 11 | + const tls = require('tls'); | ||
| 12 | + const tlsSocketKeyLog = tls.connect('cause-error'); | ||
| 13 | + tlsSocketKeyLog.on('error', common.mustCall()); | ||
| 14 | + tlsSocketKeyLog.on('close', common.mustCall(() => { | ||
| 15 | + tlsSocketKeyLog.on('keylog', common.mustNotCall()); | ||
| 16 | + })); | ||
| 17 | + | ||
| 18 | + const tlsSocketSession = tls.connect('cause-error-2'); | ||
| 19 | + tlsSocketSession.on('error', common.mustCall()); | ||
| 20 | + tlsSocketSession.on('close', common.mustCall(() => { | ||
| 21 | + tlsSocketSession.on('session', common.mustNotCall()); | ||
| 22 | + })); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments