Commit 4e7a31b
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: #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>1 parent 7165f1d commit 4e7a31bCopy full SHA for 4e7a31b
File tree
Expand file treeCollapse file tree
3 files changed
+18
-4
lines changedOpen diff view settings
Filter options
- lib
- internal
- test/parallel
Expand file treeCollapse file tree
3 files changed
+18
-4
lines changedOpen diff view settings
Collapse file
+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
158 | 158 | |
159 | 159 | |
160 | 160 | |
161 | | - |
| 161 | + |
162 | 162 | |
163 | 163 | |
164 | 164 | |
|
Collapse file
+3-3Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
22 | 22 | |
23 | 23 | |
24 | 24 | |
25 | | - |
26 | | - |
27 | | - |
| 25 | + |
| 26 | + |
| 27 | + |
28 | 28 | |
29 | 29 | |
30 | 30 | |
|
Collapse file
test/parallel/test-crypto.js
Copy file name to clipboardExpand all lines: test/parallel/test-crypto.js+14Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
97 | 97 | |
98 | 98 | |
99 | 99 | |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | + |
| 112 | + |
| 113 | + |
100 | 114 | |
101 | 115 | |
102 | 116 | |
|
0 commit comments