From e374e165c2ee372e9c6d10860ea6ef47f180f6b2 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sun, 2 Oct 2022 07:12:21 +0100 Subject: gentoo auto-resync : 02:10:2022 - 07:12:21 --- ...-getrandom-and-arc4random_buf-usage-order.patch | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 sys-libs/minizip-ng/files/minizip-ng-3.0.6-Switch-getrandom-and-arc4random_buf-usage-order.patch (limited to 'sys-libs/minizip-ng/files/minizip-ng-3.0.6-Switch-getrandom-and-arc4random_buf-usage-order.patch') diff --git a/sys-libs/minizip-ng/files/minizip-ng-3.0.6-Switch-getrandom-and-arc4random_buf-usage-order.patch b/sys-libs/minizip-ng/files/minizip-ng-3.0.6-Switch-getrandom-and-arc4random_buf-usage-order.patch new file mode 100644 index 000000000000..92db9c05b5d1 --- /dev/null +++ b/sys-libs/minizip-ng/files/minizip-ng-3.0.6-Switch-getrandom-and-arc4random_buf-usage-order.patch @@ -0,0 +1,68 @@ +https://github.com/zlib-ng/minizip-ng/pull/651 + +From 1be6ea22e127a99786aefd2896e08bab43ad1333 Mon Sep 17 00:00:00 2001 +From: Sam James +Date: Sun, 2 Oct 2022 01:39:17 +0100 +Subject: [PATCH] Switch getrandom() and arc4random_buf() usage order + +We need to match the order of inclusions at the top of the file +otherwise we might end up trying to use arc4random_buf() when +available (because HAVE_ARC4RANODM_BUF is set) even though +we hit HAVE_GETRANDOM first above and only included + because of it. + +Besides, if getrandom() is available, we should really prefer +it anyway. + +Fixes an implicit function declaration: +``` +minizip-ng-3.0.6/mz_os_posix.c:124:5: error: implicit declaration of function 'arc4random_buf' [-Werror=implicit-function-declaration] +``` +--- a/mz_os_posix.c ++++ b/mz_os_posix.c +@@ -117,7 +117,22 @@ void mz_os_utf8_string_delete(uint8_t **string) { + + /***************************************************************************/ + +-#if defined(HAVE_ARC4RANDOM_BUF) ++#if defined(HAVE_GETRANDOM) ++int32_t mz_os_rand(uint8_t *buf, int32_t size) { ++ int32_t left = size; ++ int32_t written = 0; ++ ++ while (left > 0) { ++ written = getrandom(buf, left, 0); ++ if (written < 0) ++ return MZ_INTERNAL_ERROR; ++ ++ buf += written; ++ left -= written; ++ } ++ return size - left; ++} ++#elif defined(HAVE_ARC4RANDOM_BUF) + int32_t mz_os_rand(uint8_t *buf, int32_t size) { + if (size < 0) + return 0; +@@ -139,21 +154,6 @@ int32_t mz_os_rand(uint8_t *buf, int32_t size) { + } + return size - left; + } +-#elif defined(HAVE_GETRANDOM) +-int32_t mz_os_rand(uint8_t *buf, int32_t size) { +- int32_t left = size; +- int32_t written = 0; +- +- while (left > 0) { +- written = getrandom(buf, left, 0); +- if (written < 0) +- return MZ_INTERNAL_ERROR; +- +- buf += written; +- left -= written; +- } +- return size - left; +-} + #else + int32_t mz_os_rand(uint8_t *buf, int32_t size) { + static unsigned calls = 0; -- cgit v1.2.3