]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
Fix #131: Compile with -fno-strict-aliasing
authorWillem Toorop <willem@nlnetlabs.nl>
Thu, 7 Oct 2021 14:49:11 +0000 (16:49 +0200)
committerWillem Toorop <willem@nlnetlabs.nl>
Thu, 7 Oct 2021 14:49:11 +0000 (16:49 +0200)
or drill will fail signature chasing

Changelog
configure.ac
sha2.c

index d4a01245e53a9504b6de471ba893c03972481a50..2aea36b57b5c404aaea6e1f035f5f123995693ba 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -49,6 +49,8 @@
        * PR #108: Fix for ldns-compare-zones net detecting when first zone
          has a RRset that shrinks from two to one RRs, or grows from one
          to two RRs. Thanks Emilio Caballero
+       * Fix #131: Drill sig chasing breaks with gcc-11 and
+         strict-aliasing. Thanks Stanislav Levin
 
 1.7.1  2019-07-26
        * bugfix: Manage verification paths for OpenSSL >= 1.1.0
index 9980bf82a1ca6b49c1a950fd9dddef9db50de767..202c09832658c62c133b9b370b9b9be9f5bef68b 100644 (file)
@@ -97,6 +97,7 @@ ACX_CHECK_COMPILER_FLAG(Wstrict-prototypes, [CFLAGS="-Wstrict-prototypes $CFLAGS
 #ACX_CHECK_COMPILER_FLAG(Wshadow, [CFLAGS="-Wshadow $CFLAGS"])
 ACX_CHECK_COMPILER_FLAG(Wunused-function, [CFLAGS="-Wunused-function $CFLAGS"])
 ACX_CHECK_COMPILER_FLAG(Wmissing-prototypes, [CFLAGS="-Wmissing-prototypes $CFLAGS"])
+ACX_CHECK_COMPILER_FLAG(fno-strict-aliasing, [CFLAGS="-fno-strict-aliasing $CFLAGS"])
 
 AC_CHECK_HEADERS([getopt.h time.h],,, [AC_INCLUDES_DEFAULT])
 
diff --git a/sha2.c b/sha2.c
index f1004f02ebec73505237b239d9d48913bb6638a0..8988ee06d04b010d0bf33a0393f111c7b72382e4 100644 (file)
--- a/sha2.c
+++ b/sha2.c
@@ -554,7 +554,7 @@ typedef union _ldns_sha2_buffer_union {
         uint64_t* theLongs;
 } ldns_sha2_buffer_union;
 
-void ldns_sha256_final(sha2_byte digest[], ldns_sha256_CTX* context) {
+void ldns_sha256_final(sha2_byte digest[LDNS_SHA256_DIGEST_LENGTH], ldns_sha256_CTX* context) {
        sha2_word32     *d = (sha2_word32*)digest;
        size_t usedspace;
        ldns_sha2_buffer_union cast_var;
@@ -905,7 +905,7 @@ static void ldns_sha512_Last(ldns_sha512_CTX* context) {
        ldns_sha512_Transform(context, (sha2_word64*)context->buffer);
 }
 
-void ldns_sha512_final(sha2_byte digest[], ldns_sha512_CTX* context) {
+void ldns_sha512_final(sha2_byte digest[LDNS_SHA512_DIGEST_LENGTH], ldns_sha512_CTX* context) {
        sha2_word64     *d = (sha2_word64*)digest;
 
        /* Sanity check: */
@@ -958,7 +958,7 @@ void ldns_sha384_update(ldns_sha384_CTX* context, const sha2_byte* data, size_t
        ldns_sha512_update((ldns_sha512_CTX*)context, data, len);
 }
 
-void ldns_sha384_final(sha2_byte digest[], ldns_sha384_CTX* context) {
+void ldns_sha384_final(sha2_byte digest[LDNS_SHA384_DIGEST_LENGTH], ldns_sha384_CTX* context) {
        sha2_word64     *d = (sha2_word64*)digest;
 
        /* Sanity check: */