-
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.
_stream_wrap: prevent use after free in TLS
Queued write requests should be invoked on handle close, otherwise the "consumer" might be already destroyed when the write callbacks of the "consumed" handle will be invoked. Same applies to the shutdown requests. Make sure to "move" away socket from server to not break the `connections` counter in `net.js`. Otherwise it might not call `close` callback, or call it too early. Fix: #1696 PR-URL: #1910 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
- Loading branch information
Showing
7 changed files
with
239 additions
and
33 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
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
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,39 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
|
||
const StreamWrap = require('_stream_wrap'); | ||
const Duplex = require('stream').Duplex; | ||
const ShutdownWrap = process.binding('stream_wrap').ShutdownWrap; | ||
|
||
var done = false; | ||
|
||
function testShutdown(callback) { | ||
var stream = new Duplex({ | ||
read: function() { | ||
}, | ||
write: function() { | ||
} | ||
}); | ||
|
||
var wrap = new StreamWrap(stream); | ||
|
||
var req = new ShutdownWrap(); | ||
req.oncomplete = function(code) { | ||
assert(code < 0); | ||
callback(); | ||
}; | ||
req.handle = wrap._handle; | ||
|
||
// Close the handle to simulate | ||
wrap.destroy(); | ||
req.handle.shutdown(req); | ||
} | ||
|
||
testShutdown(function() { | ||
done = true; | ||
}); | ||
|
||
process.on('exit', function() { | ||
assert(done); | ||
}); |
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
Oops, something went wrong.