aboutsummaryrefslogtreecommitdiff
path: root/lib/internal/util.js
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2017-01-13 14:28:35 -0800
committerRich Trott <rtrott@gmail.com>2017-01-16 20:32:23 -0800
commit56950674d6f56e1577df2affcf884619d91fa0bf (patch)
tree08c0b25e6b2a90d31251c16d2f4c7ead57803913 /lib/internal/util.js
parent38ae95bb0c0c002b7b04040b0aa060e00b760cdd (diff)
downloadandroid-node-v8-56950674d6f56e1577df2affcf884619d91fa0bf.tar.gz
android-node-v8-56950674d6f56e1577df2affcf884619d91fa0bf.tar.bz2
android-node-v8-56950674d6f56e1577df2affcf884619d91fa0bf.zip
crypto,tls: fix mutability of return values
If you alter the array returned by `tls.getCiphers()`, `crypto.getCiphers()`, `crypto.getHashes()`, or `crypto.getCurves()`, it will alter subsequent return values from those functions. ```js 'use strict'; const crypto = require('crypto'); var hashes = crypto.getHashes(); hashes.splice(0, hashes.length); hashes.push('some-arbitrary-value'); console.log(crypto.getHashes()); // "['some-arbitrary-value']" ``` This is surprising. Change functions to return copy of array instead. PR-URL: https://github.com/nodejs/node/pull/10795 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Diffstat (limited to 'lib/internal/util.js')
-rw-r--r--lib/internal/util.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/internal/util.js b/lib/internal/util.js
index b7facfbbbf..5384d59fc5 100644
--- a/lib/internal/util.js
+++ b/lib/internal/util.js
@@ -158,7 +158,7 @@ exports.cachedResult = function cachedResult(fn) {
return () => {
if (result === undefined)
result = fn();
- return result;
+ return result.slice();
};
};