From: Nikos Mavrogiannopoulos Date: Fri, 31 Jan 2014 13:04:58 +0000 (+0100) Subject: Added sanity check in hash_init() and mac_init(). X-Git-Tag: gnutls_3_3_0pre0~227 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dacc1b9cd8822b1cd2a48dd7c463849632a8d7eb;p=thirdparty%2Fgnutls.git Added sanity check in hash_init() and mac_init(). --- diff --git a/lib/gnutls_hash_int.c b/lib/gnutls_hash_int.c index 51a4420194..bdc9055721 100644 --- a/lib/gnutls_hash_int.c +++ b/lib/gnutls_hash_int.c @@ -37,6 +37,9 @@ int _gnutls_hash_init(digest_hd_st * dig, const mac_entry_st * e) FAIL_IF_LIB_ERROR; + if (unlikely(e == NULL || e->id == GNUTLS_MAC_NULL)) + return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST); + dig->e = e; /* check if a digest has been registered @@ -187,6 +190,9 @@ _gnutls_mac_init(mac_hd_st * mac, const mac_entry_st * e, FAIL_IF_LIB_ERROR; + if (unlikely(e == NULL || e->id == GNUTLS_MAC_NULL)) + return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST); + mac->e = e; mac->mac_len = _gnutls_mac_get_algo_len(e);