Skip to content

Commit caf22f0

Browse files
committed
tls: fix abort on negative zero sessionTimeout
validateInt32() accepts -0, but the binding asserts IsInt32(), which V8 reports as false for -0, so the process aborts. Coerce the value to +0 before passing it to setSessionTimeout(). Signed-off-by: JuHyeong424 <wkdwngud963@gmail.com>
1 parent dcaf43a commit caf22f0

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

‎lib/internal/tls/secure-context.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,8 @@ function configSecureContext(context, options = kEmptyObject, name = 'options')
328328

329329
if (sessionTimeout !== undefined && sessionTimeout !== null) {
330330
validateInt32(sessionTimeout, `${name}.sessionTimeout`, 0);
331-
context.setSessionTimeout(sessionTimeout);
331+
// Coerce -0 to +0, which the binding does not treat as an Int32.
332+
context.setSessionTimeout(sessionTimeout | 0);
332333
}
333334
}
334335

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
if (!common.hasCrypto)
5+
common.skip('missing crypto');
6+
7+
const tls = require('tls');
8+
9+
tls.createSecureContext({ sessionTimeout: -0 });

0 commit comments

Comments
 (0)