Commit 45a8376
crypto: fix UB in computing max message size
Before this commit it computed `(1<<(8*(15-iv_len)))-1` for `iv_len>=11`
and that reduces to `(1<<32)-1` for `iv_len==11`. Left-shifting past
the sign bit and overflowing a signed integral type are both undefined
behaviors.
This commit switches to fixed values and restricts the `iv_len==11`
case to `INT_MAX`, as was already the case for all `iv_len<=10`.
PR-URL: #21462
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>1 parent a48d98e commit 45a8376Copy full SHA for 45a8376
File tree
Expand file treeCollapse file tree
2 files changed
+14
-7
lines changedOpen diff view settings
Filter options
- src
- test/parallel
Expand file treeCollapse file tree
2 files changed
+14
-7
lines changedOpen diff view settings
Collapse file
+4-7Lines changed: 4 additions & 7 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
39 | 39 | |
40 | 40 | |
41 | 41 | |
42 | | - |
43 | 42 | |
44 | 43 | |
45 | 44 | |
| ||
2802 | 2801 | |
2803 | 2802 | |
2804 | 2803 | |
2805 | | - |
| 2804 | + |
2806 | 2805 | |
2807 | | - |
2808 | | - |
2809 | | - |
2810 | | - |
2811 | | - |
| 2806 | + |
| 2807 | + |
| 2808 | + |
2812 | 2809 | |
2813 | 2810 | |
2814 | 2811 | |
|
Collapse file
test/parallel/test-crypto-authenticated.js
Copy file name to clipboardExpand all lines: test/parallel/test-crypto-authenticated.js+10Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1017 | 1017 | |
1018 | 1018 | |
1019 | 1019 | |
| 1020 | + |
| 1021 | + |
| 1022 | + |
| 1023 | + |
| 1024 | + |
| 1025 | + |
| 1026 | + |
| 1027 | + |
| 1028 | + |
| 1029 | + |
0 commit comments