From 5612e721b826ed8054f0439eec9eafef172635c9 Mon Sep 17 00:00:00 2001 From: philsmd Date: Tue, 14 Feb 2017 13:21:11 +0100 Subject: [PATCH] minor: use memset () before memcpy () in cpu MD5 function --- src/cpu_md5.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cpu_md5.c b/src/cpu_md5.c index 8c262153c..4c4252339 100644 --- a/src/cpu_md5.c +++ b/src/cpu_md5.c @@ -155,12 +155,14 @@ void md5_complete_no_limit (u32 digest[4], u32 *plain, u32 plain_len) int cur_len = MIN (block_total_len, remaining_len); int copy_len = MAX (cur_len, 0); // should never be negative of course + // initialize the block + + memset (block_ptr, 0, block_total_len); + + // copy the bytes from the plain pointer (plain_ptr) + memcpy (block_ptr, plain_ptr, (size_t) copy_len); - // clear the remaining bytes of the block - - memset (block_ptr + copy_len, 0, (size_t) block_total_len - (size_t) copy_len); - /* * final block */