From 7ec3cbe54de4a620e884ab77f2996f175015c815 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 3 May 2026 22:48:19 +0200 Subject: Ensure HWCAP_SHA1-check does not modify errno MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- process.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'process.c') diff --git a/process.c b/process.c index 041383d..0ba8eed 100644 --- a/process.c +++ b/process.c @@ -1,5 +1,6 @@ /* See LICENSE file for copyright and license details. */ #include "common.h" +#include #include #if defined(__SSE4_1__) && defined(__SSSE3__) && defined(__SSE2__) && defined(__SHA__) @@ -483,6 +484,7 @@ have_sha_intrinsics(void) { static volatile int ret = -1; static volatile atomic_flag spinlock = ATOMIC_FLAG_INIT; + int saved_errno; if (ret != -1) return ret; @@ -492,10 +494,12 @@ have_sha_intrinsics(void) if (ret != -1) goto out; + saved_errno = errno; if (getauxval(AT_HWCAP) & HWCAP_SHA1) ret = 1; else ret = 0; + errno = saved_errno; out: atomic_flag_clear(&spinlock); -- cgit v1.2.3-70-g09d2