Skip to content

Commit

Permalink
fixup! tls: validate ticket keys buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Apr 20, 2021
1 parent 72d211b commit 661ec67
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions test/parallel/test-tls-ticket-invalid-arg.js
Expand Up @@ -7,16 +7,18 @@ if (!common.hasCrypto) {
const assert = require('assert');
const tls = require('tls');

[null, undefined, 0, 1, 1n, Symbol(), {}, [], true, false, ''].forEach(
(arg) =>
assert.throws(() => {
new tls.Server().setTicketKeys(arg);
}, /"buffer" argument must be an instance of Buffer, TypedArray, or DataView/)
);
const server = new tls.Server();

[null, undefined, 0, 1, 1n, Symbol(), {}, [], true, false, '', () => {}]
.forEach((arg) =>
assert.throws(
() => server.setTicketKeys(arg),
{ code: 'ERR_INVALID_ARG_TYPE' }
));

[new Uint8Array(1), Buffer.from([1]), new DataView(new ArrayBuffer(2))].forEach(
(arg) =>
assert.throws(() => {
new tls.Server().setTicketKeys(arg);
server.setTicketKeys(arg);
}, /Session ticket keys must be a 48-byte buffer/)
);

0 comments on commit 661ec67

Please sign in to comment.