talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit ab7e2b272a7c5017296571c38cf0c263989a35ab
parent 592f6d132518eb0609953a178adffd20a9151d1b
Author: Andrej Kacian <ticho@claws-mail.org>
Date:   Fri, 31 Aug 2018 13:28:16 +0200

Add parameter sanity checks to md5_hex_digest() and md5_hex_hmac().

Diffstat:
Msrc/common/md5.c | 8++++++++
1 file changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/common/md5.c b/src/common/md5.c @@ -384,6 +384,8 @@ md5_hex_digest_file(char *hexdigest, const unsigned char *file) void md5_hex_digest(char *hexdigest, const unsigned char *s) { + g_return_if_fail(hexdigest != NULL); + g_return_if_fail(s != NULL); md5_hex_digest_binary(hexdigest, s, strlen(s)); } @@ -469,6 +471,12 @@ md5_hex_hmac(char *hexdigest, unsigned char digest[16]; int i; + g_return_if_fail(key != NULL); + g_return_if_fail(key_len >= 0); + g_return_if_fail(text != NULL); + g_return_if_fail(text_len >= 0); + g_return_if_fail(hexdigest != NULL); + md5_hmac(digest, text, text_len, key, key_len); for (i = 0; i < 16; i++) sprintf(hexdigest + 2 * i, "%02x", digest[i]);