From 7e9bd41a83710b4b68abca1dfa524796b264398d Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Wed, 31 May 2023 10:48:52 +0200 Subject: [PATCH] src/libsecp256k1/rng.h: fix C467 warning on MSVC compilers. --- src/libsecp256k1/rng.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libsecp256k1/rng.h b/src/libsecp256k1/rng.h index 103583f..f476963 100644 --- a/src/libsecp256k1/rng.h +++ b/src/libsecp256k1/rng.h @@ -42,12 +42,17 @@ static int fill_random(unsigned char* data, size_t size) { #if defined(_WIN32) +/* Disable C4267 Warning (dataloss when casting variable to smaller size) temporarily */ +#pragma warning( push ) +#pragma warning( disable: 4267 ) NTSTATUS res = BCryptGenRandom(NULL, data, size, BCRYPT_USE_SYSTEM_PREFERRED_RNG); +#pragma warning( pop ) if (res != STATUS_SUCCESS || size > ULONG_MAX) { return 0; } else { return 1; } + #elif defined(__linux__) || defined(__FreeBSD__) /* If `getrandom(2)` is not available you should fallback to /dev/urandom */ ssize_t res = getrandom(data, size, 0);