mirror of https://github.com/lukechilds/node.git
Browse Source
Unchecked argument conversion in Parser::Consume crashes node in an slightly undesirable manner - 'unreachable code' in parser. Make sure we validate the incoming type at the earliest point. PR-URL: https://github.com/nodejs/node/pull/12288 Fixes: https://github.com/nodejs/node/issues/12178 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Refael Ackermann <refack@gmail.com>v6
Gireesh Punathil
8 years ago
committed by
Refael Ackermann
2 changed files with 29 additions and 0 deletions
@ -0,0 +1,28 @@ |
|||||
|
'use strict'; |
||||
|
const common = require('../common'); |
||||
|
const assert = require('assert'); |
||||
|
const http = require('http'); |
||||
|
const spawn = require('child_process').spawn; |
||||
|
|
||||
|
if (process.argv[2] === 'child') { |
||||
|
const server = http.createServer(common.mustCall((req, res) => { |
||||
|
res.end('hello'); |
||||
|
})); |
||||
|
|
||||
|
server.listen(0, common.mustCall((s) => { |
||||
|
const rr = http.get( |
||||
|
{ port: server.address().port }, |
||||
|
common.mustCall((d) => { |
||||
|
// This bad input (0) should abort the parser and the process
|
||||
|
rr.parser.consume(0); |
||||
|
server.close(); |
||||
|
})); |
||||
|
})); |
||||
|
} else { |
||||
|
const child = spawn(process.execPath, [__filename, 'child'], |
||||
|
{ stdio: 'inherit' }); |
||||
|
child.on('exit', common.mustCall((code, signal) => { |
||||
|
assert(common.nodeProcessAborted(code, signal), |
||||
|
'process should have aborted, but did not'); |
||||
|
})); |
||||
|
} |
Loading…
Reference in new issue