Skip to content

Commit ea0596f

Browse files
committed
Merge branch 'develop' into next
2 parents 1c623bb + 0eeccf5 commit ea0596f

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

modules/core/src/System/Guid.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <algorithm>
1212
#include <array>
1313
#include <cstddef>
14+
#include <limits>
1415
#include <thread>
1516
#include <utility>
1617

@@ -402,8 +403,9 @@ namespace System {
402403
// BCRYPT_USE_SYSTEM_PREFERRED_RNG needs no algorithm handle, which
403404
// is what lets this stay a leaf call with no initialisation state.
404405
while (length > 0) {
405-
const ULONG chunk =
406-
static_cast<ULONG>(length > 0xFFFFFFFFull ? 0xFFFFFFFFull : length);
406+
constexpr std::size_t maxChunk =
407+
static_cast<std::size_t>(std::numeric_limits<ULONG>::max());
408+
const ULONG chunk = static_cast<ULONG>(std::min(length, maxChunk));
407409
if (BCryptGenRandom(nullptr, reinterpret_cast<PUCHAR>(buffer), chunk,
408410
BCRYPT_USE_SYSTEM_PREFERRED_RNG) >= 0) {
409411
buffer += chunk;

0 commit comments

Comments
 (0)