From a2aae6a58292c6e4f754339f4750312709bf3be3 Mon Sep 17 00:00:00 2001 From: Daniel Bertalan Date: Fri, 24 Dec 2021 12:10:29 +0100 Subject: [PATCH] LibCrypto: Remove redundant __builtin_memset() call This call caused GCC 12's static analyzer to think that we perform an out-of-bounds write to the v_key Vector. This is obviously incorrect, and comes from the fact that GCC doesn't properly track whether we use the inline storage, or the Vector is allocated on the heap. While searching for a workaround, Sam pointed out that this call is redundant as `Vector::resize()` already zeroes out the elements, so we can completely remove it. Co-authored-by: Sam Atkins --- Userland/Libraries/LibCrypto/Authentication/HMAC.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Userland/Libraries/LibCrypto/Authentication/HMAC.h b/Userland/Libraries/LibCrypto/Authentication/HMAC.h index 55d919c238..c1abba3956 100644 --- a/Userland/Libraries/LibCrypto/Authentication/HMAC.h +++ b/Userland/Libraries/LibCrypto/Authentication/HMAC.h @@ -85,7 +85,6 @@ private: // Note: The block size of all the current hash functions is 512 bits. Vector v_key; v_key.resize(block_size); - __builtin_memset(v_key.data(), 0, block_size); auto key_buffer = v_key.span(); // m_key_data is zero'd, so copying the data in // the first few bytes leaves the rest zero, which