Skip to content

Commit 00d49ad

Browse files
sam-githubaddaleax
authored andcommittedFeb 6, 2019
tls: null not valid as a renegotiate callback
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]>
1 parent 6da82b1 commit 00d49ad

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
 

‎lib/_tls_wrap.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ TLSSocket.prototype._init = function(socket, wrap) {
601601
TLSSocket.prototype.renegotiate = function(options, callback) {
602602
if (options === null || typeof options !== 'object')
603603
throw new ERR_INVALID_ARG_TYPE('options', 'Object', options);
604-
if (callback != null && typeof callback !== 'function')
604+
if (callback !== undefined && typeof callback !== 'function')
605605
throw new ERR_INVALID_CALLBACK();
606606

607607
if (this.destroyed)

‎test/parallel/test-tls-disable-renegotiation.js

+6
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ server.listen(0, common.mustCall(() => {
6363
type: TypeError,
6464
});
6565

66+
common.expectsError(() => client.renegotiate({}, null), {
67+
code: 'ERR_INVALID_CALLBACK',
68+
type: TypeError,
69+
});
70+
71+
6672
// Negotiation is still permitted for this first
6773
// attempt. This should succeed.
6874
let ok = client.renegotiate(options, common.mustCall((err) => {

0 commit comments

Comments
 (0)