Commit 57e7ed7
src: fix CSPRNG when length exceeds INT_MAX
CSPRNG implicitly casts the size_t length argument to a signed int when
calling RAND_bytes(), which leaves it up to the caller to ensure that
the length argument actually fits into such a signed int. However, not
all call sites explicitly ensure that, which could lead to subtle bugs.
In OpenSSL 3, use RAND_bytes_ex() instead, which does not require
casting the length to a signed int.
In OpenSSL 1.1.1, RAND_bytes_ex() is not supported, thus we have to
process blocks of size INT_MAX one by one.
PR-URL: #47515
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>1 parent 35e8b3b commit 57e7ed7Copy full SHA for 57e7ed7
File tree
Expand file treeCollapse file tree
1 file changed
+12
-2
lines changedOpen diff view settings
Filter options
- src/crypto
Expand file treeCollapse file tree
1 file changed
+12
-2
lines changedOpen diff view settings
Collapse file
+12-2Lines changed: 12 additions & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
61 | 61 | |
62 | 62 | |
63 | 63 | |
| 64 | + |
64 | 65 | |
65 | | - |
66 | | - |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | + |
67 | 75 | |
| 76 | + |
| 77 | + |
68 | 78 | |
69 | 79 | |
70 | 80 | |
|
0 commit comments