|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const common = require('../common'); |
| 4 | + |
| 5 | +if (!common.hasCrypto) |
| 6 | + common.skip('missing crypto'); |
| 7 | + |
| 8 | +const http2 = require('http2'); |
| 9 | +const net = require('net'); |
| 10 | +const h2test = require('../common/http2'); |
| 11 | + |
| 12 | +const server = http2.createServer(); |
| 13 | +server.on('stream', common.mustNotCall()); |
| 14 | + |
| 15 | +const settings = new h2test.SettingsFrame(); |
| 16 | +const settingsAck = new h2test.SettingsFrame(true); |
| 17 | +const altsvc = new h2test.AltSvcFrame((1 << 14) + 1); |
| 18 | + |
| 19 | +server.listen(0, () => { |
| 20 | + const client = net.connect(server.address().port, () => { |
| 21 | + client.write(h2test.kClientMagic, () => { |
| 22 | + client.write(settings.data, () => { |
| 23 | + client.write(settingsAck.data); |
| 24 | + // Prior to nghttp2 1.31.1, sending this malformed altsvc frame |
| 25 | + // would cause a segfault. This test is successful if a segfault |
| 26 | + // does not occur. |
| 27 | + client.write(altsvc.data, common.mustCall(() => { |
| 28 | + client.destroy(); |
| 29 | + })); |
| 30 | + }); |
| 31 | + }); |
| 32 | + }); |
| 33 | + |
| 34 | + // An error may or may not be emitted on the client side, we don't care |
| 35 | + // either way if it is, but we don't want to die if it is. |
| 36 | + client.on('error', () => {}); |
| 37 | + client.on('close', common.mustCall(() => server.close())); |
| 38 | + client.resume(); |
| 39 | +}); |
0 commit comments