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>
parent
38ae95bb
Please register or sign in to comment