Skip to content

Commit 00d49ad

Browse files
sam-githubaddaleax
authored andcommitted
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‎

Lines changed: 1 addition & 1 deletion
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||typeofoptions!=='object')
603603
thrownewERR_INVALID_ARG_TYPE('options','Object',options);
604-
if(callback!=null&&typeofcallback!=='function')
604+
if(callback!==undefined&&typeofcallback!=='function')
605605
thrownewERR_INVALID_CALLBACK();
606606

607607
if(this.destroyed)

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

Lines changed: 6 additions & 0 deletions
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
letok=client.renegotiate(options,common.mustCall((err)=>{

0 commit comments

Comments
(0)