-
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.
test: add regression test for nghttp2 CVE-2018-1000168
PR-URL: https://github.com/nodejs-private/node-private/pull/124 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Evan Lucas <[email protected]>
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 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,39 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
|
||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
|
||
const http2 = require('http2'); | ||
const net = require('net'); | ||
const h2test = require('../common/http2'); | ||
|
||
const server = http2.createServer(); | ||
server.on('stream', common.mustNotCall()); | ||
|
||
const settings = new h2test.SettingsFrame(); | ||
const settingsAck = new h2test.SettingsFrame(true); | ||
const altsvc = new h2test.AltSvcFrame((1 << 14) + 1); | ||
|
||
server.listen(0, () => { | ||
const client = net.connect(server.address().port, () => { | ||
client.write(h2test.kClientMagic, () => { | ||
client.write(settings.data, () => { | ||
client.write(settingsAck.data); | ||
// Prior to nghttp2 1.31.1, sending this malformed altsvc frame | ||
// would cause a segfault. This test is successful if a segfault | ||
// does not occur. | ||
client.write(altsvc.data, common.mustCall(() => { | ||
client.destroy(); | ||
})); | ||
}); | ||
}); | ||
}); | ||
|
||
// An error may or may not be emitted on the client side, we don't care | ||
// either way if it is, but we don't want to die if it is. | ||
client.on('error', () => {}); | ||
client.on('close', common.mustCall(() => server.close())); | ||
client.resume(); | ||
}); |