mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 00:20:08 +01:00
http2: do not crash on mismatched ping buffer length
PR-URL: https://github.com/nodejs/node/pull/60135 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
642a7c0d46
commit
535efea962
|
|
@ -1444,9 +1444,9 @@ class Http2Session extends EventEmitter {
|
|||
}
|
||||
if (payload) {
|
||||
validateBuffer(payload, 'payload');
|
||||
}
|
||||
if (payload && payload.length !== 8) {
|
||||
throw new ERR_HTTP2_PING_LENGTH();
|
||||
if (payload.byteLength !== 8) {
|
||||
throw new ERR_HTTP2_PING_LENGTH();
|
||||
}
|
||||
}
|
||||
validateFunction(callback, 'callback');
|
||||
|
||||
|
|
|
|||
|
|
@ -64,11 +64,11 @@ server.listen(0, common.mustCall(() => {
|
|||
})));
|
||||
}
|
||||
{
|
||||
const payload = Buffer.from('abcdefgi');
|
||||
const payload = new Uint16Array([1, 2, 3, 4]);
|
||||
assert(client.ping(payload, common.mustCall((err, duration, ret) => {
|
||||
assert.strictEqual(err, null);
|
||||
assert.strictEqual(typeof duration, 'number');
|
||||
assert.deepStrictEqual(payload, ret);
|
||||
assert.deepStrictEqual(payload.buffer, ret.buffer);
|
||||
})));
|
||||
}
|
||||
|
||||
|
|
@ -99,7 +99,8 @@ server.listen(0, common.mustCall(() => {
|
|||
{
|
||||
const shortPayload = Buffer.from('abcdefg');
|
||||
const longPayload = Buffer.from('abcdefghi');
|
||||
[shortPayload, longPayload].forEach((payloadWithInvalidLength) =>
|
||||
const mismatchedPayload = new Uint32Array(8);
|
||||
[shortPayload, longPayload, mismatchedPayload].forEach((payloadWithInvalidLength) =>
|
||||
assert.throws(
|
||||
() => client.ping(payloadWithInvalidLength),
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user