]> granicus.if.org Git - libevent/commitdiff
sha1: ignore -Wstringop-overread warning
authorAzat Khuzhin <azat@libevent.org>
Sat, 12 Nov 2022 16:56:51 +0000 (17:56 +0100)
committerAzat Khuzhin <azat@libevent.org>
Sat, 12 Nov 2022 16:56:51 +0000 (17:56 +0100)
Fixes the following:

    [4/38] Building C object CMakeFiles/event_shared.dir/sha1.c.o
    In function ‘SHA1Update’,
        inlined from ‘SHA1Final’ at /src/le/libevent/sha1.c:274:5,
        inlined from ‘builtin_SHA1’ at /src/le/libevent/sha1.c:292:5:
    /src/le/libevent/sha1.c:228:13: warning: ‘SHA1Transform’ reading 64 bytes from a region of size 7 [-Wstringop-overread]
      228 |             SHA1Transform(context->state, *(const unsigned char (*)[64])&data[i]);
          |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /src/le/libevent/sha1.c:228:13: note: referencing argument 2 of type ‘const unsigned char[64]’
    /src/le/libevent/sha1.c: In function ‘builtin_SHA1’:
    /src/le/libevent/sha1.c:80:13: note: in a call to function ‘SHA1Transform’
       80 | static void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]) {
          |             ^~~~~~~~~~~~~

sha1.c

diff --git a/sha1.c b/sha1.c
index c8e23da28fc76259a5b2fca21b959890d5de5803..09cf6e695aca6a1cf0ca6a09741ae15f62d3182b 100644 (file)
--- a/sha1.c
+++ b/sha1.c
@@ -17,6 +17,14 @@ A million repetitions of "a"
 
 #define SHA1HANDSOFF
 
+#if defined(__clang__)
+#elif defined(__GNUC__)
+#pragma GCC diagnostic push
+/* Ignore the case when SHA1Transform() called with 'char *', that code passed
+ * buffer of 64 bytes anyway (at least now) */
+#pragma GCC diagnostic ignored "-Wstringop-overread"
+#endif
+
 #include <stdio.h>
 #include <string.h>