From 7ceeaca0dc42cb1b7b612c20bf7ca89bd4d75fb0 Mon Sep 17 00:00:00 2001 From: Michal Nowak Date: Mon, 17 May 2021 14:36:28 +0200 Subject: [PATCH] Fix arguments with mismatched bound in lib/isc/sha2.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC 11 produced the following warnings: sha2.c:888:26: error: argument 1 of type ‘uint8_t[]’ {aka ‘unsigned char[]’} with mismatched bound [-Werror=array-parameter=] 888 | isc_sha224_final(uint8_t digest[], isc_sha224_t *context) { | ~~~~~~~~^~~~~~~~ In file included from sha2.c:58: ./include/isc/sha2.h:132:24: note: previously declared as ‘uint8_t[28]’ {aka ‘unsigned char[28]’} 132 | void isc_sha224_final (uint8_t[ISC_SHA224_DIGESTLENGTH], isc_sha224_t *); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sha2.c:1151:26: error: argument 1 of type ‘uint8_t[]’ {aka ‘unsigned char[]’} with mismatched bound [-Werror=array-parameter=] 1151 | isc_sha256_final(uint8_t digest[], isc_sha256_t *context) { | ~~~~~~~~^~~~~~~~ In file included from sha2.c:58: ./include/isc/sha2.h:139:24: note: previously declared as ‘uint8_t[32]’ {aka ‘unsigned char[32]’} 139 | void isc_sha256_final (uint8_t[ISC_SHA256_DIGESTLENGTH], isc_sha256_t *); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sha2.c:1514:31: error: argument 1 of type ‘uint8_t[]’ {aka ‘unsigned char[]’} with mismatched bound [-Werror=array-parameter=] 1514 | void isc_sha512_final(uint8_t digest[], isc_sha512_t *context) { | ~~~~~~~~^~~~~~~~ In file included from sha2.c:58: ./include/isc/sha2.h:153:24: note: previously declared as ‘uint8_t[64]’ {aka ‘unsigned char[64]’} 153 | void isc_sha512_final (uint8_t[ISC_SHA512_DIGESTLENGTH], isc_sha512_t *); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sha2.c:1567:26: error: argument 1 of type ‘uint8_t[]’ {aka ‘unsigned char[]’} with mismatched bound [-Werror=array-parameter=] 1567 | isc_sha384_final(uint8_t digest[], isc_sha384_t *context) { | ~~~~~~~~^~~~~~~~ In file included from sha2.c:58: ./include/isc/sha2.h:146:24: note: previously declared as ‘uint8_t[48]’ {aka ‘unsigned char[48]’} 146 | void isc_sha384_final (uint8_t[ISC_SHA384_DIGESTLENGTH], isc_sha384_t *); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sha2.c:1604:44: error: argument 2 of type ‘char[]’ with mismatched bound [-Werror=array-parameter=] 1604 | isc_sha224_end(isc_sha224_t *context, char buffer[]) { | ~~~~~^~~~~~~~ In file included from sha2.c:58: ./include/isc/sha2.h:133:39: note: previously declared as ‘char[57]’ 133 | char *isc_sha224_end (isc_sha224_t *, char[ISC_SHA224_DIGESTSTRINGLENGTH]); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sha2.c:1645:44: error: argument 2 of type ‘char[]’ with mismatched bound [-Werror=array-parameter=] 1645 | isc_sha256_end(isc_sha256_t *context, char buffer[]) { | ~~~~~^~~~~~~~ In file included from sha2.c:58: ./include/isc/sha2.h:140:39: note: previously declared as ‘char[65]’ 140 | char *isc_sha256_end (isc_sha256_t *, char[ISC_SHA256_DIGESTSTRINGLENGTH]); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sha2.c:1686:44: error: argument 2 of type ‘char[]’ with mismatched bound [-Werror=array-parameter=] 1686 | isc_sha512_end(isc_sha512_t *context, char buffer[]) { | ~~~~~^~~~~~~~ In file included from sha2.c:58: ./include/isc/sha2.h:154:39: note: previously declared as ‘char[129]’ 154 | char *isc_sha512_end (isc_sha512_t *, char[ISC_SHA512_DIGESTSTRINGLENGTH]); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sha2.c:1727:44: error: argument 2 of type ‘char[]’ with mismatched bound [-Werror=array-parameter=] 1727 | isc_sha384_end(isc_sha384_t *context, char buffer[]) { | ~~~~~^~~~~~~~ In file included from sha2.c:58: ./include/isc/sha2.h:147:39: note: previously declared as ‘char[97]’ 147 | char *isc_sha384_end (isc_sha384_t *, char[ISC_SHA384_DIGESTSTRINGLENGTH]); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors --- lib/isc/sha2.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/isc/sha2.c b/lib/isc/sha2.c index 36444a720d..951d1bb88e 100644 --- a/lib/isc/sha2.c +++ b/lib/isc/sha2.c @@ -885,7 +885,7 @@ isc_sha224_update(isc_sha224_t *context, const uint8_t* data, size_t len) { } void -isc_sha224_final(uint8_t digest[], isc_sha224_t *context) { +isc_sha224_final(uint8_t digest[ISC_SHA224_DIGESTLENGTH], isc_sha224_t *context) { uint8_t sha256_digest[ISC_SHA256_DIGESTLENGTH]; isc_sha256_final(sha256_digest, (isc_sha256_t *)context); memmove(digest, sha256_digest, ISC_SHA224_DIGESTLENGTH); @@ -1148,7 +1148,7 @@ isc_sha256_update(isc_sha256_t *context, const uint8_t *data, size_t len) { } void -isc_sha256_final(uint8_t digest[], isc_sha256_t *context) { +isc_sha256_final(uint8_t digest[ISC_SHA256_DIGESTLENGTH], isc_sha256_t *context) { uint32_t *d = (uint32_t*)digest; unsigned int usedspace; @@ -1511,7 +1511,7 @@ void isc_sha512_last(isc_sha512_t *context) { isc_sha512_transform(context, (uint64_t*)context->buffer); } -void isc_sha512_final(uint8_t digest[], isc_sha512_t *context) { +void isc_sha512_final(uint8_t digest[ISC_SHA512_DIGESTLENGTH], isc_sha512_t *context) { uint64_t *d = (uint64_t*)digest; /* Sanity check: */ @@ -1564,7 +1564,7 @@ isc_sha384_update(isc_sha384_t *context, const uint8_t* data, size_t len) { } void -isc_sha384_final(uint8_t digest[], isc_sha384_t *context) { +isc_sha384_final(uint8_t digest[ISC_SHA384_DIGESTLENGTH], isc_sha384_t *context) { uint64_t *d = (uint64_t*)digest; /* Sanity check: */ @@ -1601,7 +1601,7 @@ isc_sha384_final(uint8_t digest[], isc_sha384_t *context) { static const char *sha2_hex_digits = "0123456789abcdef"; char * -isc_sha224_end(isc_sha224_t *context, char buffer[]) { +isc_sha224_end(isc_sha224_t *context, char buffer[ISC_SHA224_DIGESTSTRINGLENGTH]) { uint8_t digest[ISC_SHA224_DIGESTLENGTH], *d = digest; unsigned int i; @@ -1642,7 +1642,7 @@ isc_sha224_data(const uint8_t *data, size_t len, } char * -isc_sha256_end(isc_sha256_t *context, char buffer[]) { +isc_sha256_end(isc_sha256_t *context, char buffer[ISC_SHA256_DIGESTSTRINGLENGTH]) { uint8_t digest[ISC_SHA256_DIGESTLENGTH], *d = digest; unsigned int i; @@ -1683,7 +1683,7 @@ isc_sha256_data(const uint8_t* data, size_t len, } char * -isc_sha512_end(isc_sha512_t *context, char buffer[]) { +isc_sha512_end(isc_sha512_t *context, char buffer[ISC_SHA512_DIGESTSTRINGLENGTH]) { uint8_t digest[ISC_SHA512_DIGESTLENGTH], *d = digest; unsigned int i; @@ -1724,7 +1724,7 @@ isc_sha512_data(const uint8_t *data, size_t len, } char * -isc_sha384_end(isc_sha384_t *context, char buffer[]) { +isc_sha384_end(isc_sha384_t *context, char buffer[ISC_SHA384_DIGESTSTRINGLENGTH]) { uint8_t digest[ISC_SHA384_DIGESTLENGTH], *d = digest; unsigned int i;