[ccan] [PATCH 5/7] crypto/ripemd160: Correct badly sized union member

David Gibson david at gibson.dropbear.id.au
Mon Apr 3 21:11:10 AEST 2017


struct ripemd160_ctx has a union for converting between u8[] and u32[]
data.  Unfortunately the u32 array has a miscalculated size, half the size
of the u8 array.  That means some accesses which are within the union can
technically overrun the u32 array.

Found by Coverity scan.

Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
---
 ccan/crypto/ripemd160/ripemd160.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ccan/crypto/ripemd160/ripemd160.h b/ccan/crypto/ripemd160/ripemd160.h
index 377a07d..56854cf 100644
--- a/ccan/crypto/ripemd160/ripemd160.h
+++ b/ccan/crypto/ripemd160/ripemd160.h
@@ -49,7 +49,7 @@ struct ripemd160_ctx {
 	uint32_t s[5];
 	uint64_t bytes;
 	union {
-		uint32_t u32[8];
+		uint32_t u32[16];
 		unsigned char u8[64];
 	} buf;
 #endif
-- 
2.9.3



More information about the ccan mailing list