-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tls: fix session and keylog add listener segfault
Fix an issue where adding a session or keylog listener on a tlsSocket after it was destroyed caused a segfault. fixes: #38133 fixes: #38135 PR-URL: #38180 Fixes: #38133 Fixes: #38135 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
- Loading branch information
Showing
2 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
|
||
// This test ensures that Node.js doesn't incur a segfault while | ||
// adding session or keylog listeners after destroy. | ||
// https://github.com/nodejs/node/issues/38133 | ||
// https://github.com/nodejs/node/issues/38135 | ||
|
||
const tls = require('tls'); | ||
const tlsSocketKeyLog = tls.connect('cause-error'); | ||
tlsSocketKeyLog.on('error', common.mustCall()); | ||
tlsSocketKeyLog.on('close', common.mustCall(() => { | ||
tlsSocketKeyLog.on('keylog', common.mustNotCall()); | ||
})); | ||
|
||
const tlsSocketSession = tls.connect('cause-error-2'); | ||
tlsSocketSession.on('error', common.mustCall()); | ||
tlsSocketSession.on('close', common.mustCall(() => { | ||
tlsSocketSession.on('session', common.mustNotCall()); | ||
})); |