mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:58:12 +00:00
LibCrypto: Remove all uses of VLAs
This removes all uses of VLAs with either Vectors with inline capacity for the expected soft upper bound, or the occasional heap allocation.
This commit is contained in:
parent
0d50d3ed1e
commit
b05beb79d4
7 changed files with 41 additions and 36 deletions
|
@ -273,9 +273,10 @@ UnsignedBigInteger random_number(const UnsignedBigInteger& min, const UnsignedBi
|
|||
UnsignedBigInteger base;
|
||||
auto size = range.trimmed_length() * sizeof(u32) + 2;
|
||||
// "+2" is intentional (see below).
|
||||
// Also, if we're about to crash anyway, at least produce a nice error:
|
||||
VERIFY(size < 8 * MiB);
|
||||
u8 buf[size];
|
||||
ByteBuffer buffer;
|
||||
buffer.grow(size);
|
||||
auto* buf = buffer.data();
|
||||
|
||||
fill_with_random(buf, size);
|
||||
UnsignedBigInteger random { buf, size };
|
||||
// At this point, `random` is a large number, in the range [0, 256^size).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue