Skip to content

Commit 433902e

Browse files
committed
tls: use primordials in wrap.js
Replace native array methods (.push) with primordials (ArrayPrototypePush) in lib/internal/tls/wrap.js for consistency and security. This improves protection against prototype pollution and aligns with the primordials pattern used throughout the codebase.
1 parent 879b95e commit 433902e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/internal/tls/wrap.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
'use strict';
2323

2424
const {
25+
ArrayPrototypePush,
2526
FunctionPrototypeCall,
2627
ObjectAssign,
2728
ObjectDefineProperty,
@@ -246,7 +247,7 @@ function callALPNCallback(protocolsBuffer) {
246247
const protocol = protocolsBuffer.slice(offset, offset + protocolLen);
247248
offset += protocolLen;
248249

249-
protocols.push(protocol.toString('ascii'));
250+
ArrayPrototypePush(protocols, protocol.toString('ascii'));
250251
}
251252

252253
const selectedProtocol = socket[kALPNCallback]({
@@ -1550,7 +1551,7 @@ Server.prototype.addContext = function(servername, context) {
15501551

15511552
const secureContext =
15521553
context instanceof common.SecureContext ? context : tls.createSecureContext(context);
1553-
this._contexts.push([re, secureContext.context]);
1554+
ArrayPrototypePush(this._contexts, [re, secureContext.context]);
15541555
};
15551556

15561557
Server.prototype[EE.captureRejectionSymbol] = function(

0 commit comments

Comments
 (0)