Skip to content

Commit

Permalink
tls: null not valid as a renegotiate callback
Browse files Browse the repository at this point in the history
Allow undefined as a callback, but do not allow null.

PR-URL: #25929
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
sam-github authored and addaleax committed Feb 6, 2019
1 parent 6da82b1 commit 00d49ad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ TLSSocket.prototype._init = function(socket, wrap) {
TLSSocket.prototype.renegotiate = function(options, callback) {
if (options === null || typeof options !== 'object')
throw new ERR_INVALID_ARG_TYPE('options', 'Object', options);
if (callback != null && typeof callback !== 'function')
if (callback !== undefined && typeof callback !== 'function')
throw new ERR_INVALID_CALLBACK();

if (this.destroyed)
Expand Down
6 changes: 6 additions & 0 deletions test/parallel/test-tls-disable-renegotiation.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ server.listen(0, common.mustCall(() => {
type: TypeError,
});

common.expectsError(() => client.renegotiate({}, null), {
code: 'ERR_INVALID_CALLBACK',
type: TypeError,
});


// Negotiation is still permitted for this first
// attempt. This should succeed.
let ok = client.renegotiate(options, common.mustCall((err) => {
Expand Down

0 comments on commit 00d49ad

Please sign in to comment.