Skip to content

Commit

Permalink
tls: refactor to avoid unsafe array iteration
Browse files Browse the repository at this point in the history
PR-URL: #37655
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
aduh95 committed Mar 13, 2021
1 parent fc6426c commit c2a792f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/_tls_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ exports.createSecureContext = function createSecureContext(options) {
// which leads to the crash later on.
if (key) {
if (ArrayIsArray(key)) {
for (const val of key) {
for (let i = 0; i < key.length; ++i) {
const val = key[i];
// eslint-disable-next-line eqeqeq
const pem = (val != undefined && val.pem !== undefined ? val.pem : val);
setKey(c.context, pem, val.passphrase || passphrase);
Expand Down

0 comments on commit c2a792f

Please sign in to comment.