From 3a22e5d30f49090d95ebff0e157b19522a38be35 Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Thu, 26 May 2016 19:29:29 +0000 Subject: crypto routines: Hint minimum buffer sizes to the compiler Use the C99 'static' keyword to hint to the compiler IVs and output digest sizes. The keyword informs the compiler of the minimum valid size for a given array. Obviously not every pointer can be validated (i.e., the compiler can produce false negative but not false positive reports). No functional change. No ABI change. Sponsored by: EMC / Isilon Storage Division --- cpukit/libmd/sha256c.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'cpukit/libmd/sha256c.c') diff --git a/cpukit/libmd/sha256c.c b/cpukit/libmd/sha256c.c index 4c0371dda7..f5a453e43b 100644 --- a/cpukit/libmd/sha256c.c +++ b/cpukit/libmd/sha256c.c @@ -283,7 +283,7 @@ SHA256_Update(SHA256_CTX * ctx, const void *in, size_t len) * and clears the context state. */ void -SHA256_Final(unsigned char digest[32], SHA256_CTX * ctx) +SHA256_Final(unsigned char digest[static SHA256_DIGEST_LENGTH], SHA256_CTX *ctx) { /* Add padding */ @@ -291,7 +291,8 @@ SHA256_Final(unsigned char digest[32], SHA256_CTX * ctx) /* Write the hash */ be32enc_vect(digest, ctx->state, 32); + be32enc_vect(digest, ctx->state, SHA256_DIGEST_LENGTH); /* Clear the context state */ - memset((void *)ctx, 0, sizeof(*ctx)); + memset(ctx, 0, sizeof(*ctx)); } -- cgit v1.2.3