talons

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

commit b253d35d119e2fdc7ac18e6c19c7baad35bf7d86
parent 0b7583815089737f643414c7ad585c86b16d71ec
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]);