]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Added sanity check in hash_init() and mac_init().
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Fri, 31 Jan 2014 13:04:58 +0000 (14:04 +0100)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Fri, 31 Jan 2014 13:04:58 +0000 (14:04 +0100)
lib/gnutls_hash_int.c

index 51a442019462fec48a5fcb8956d178a4fb1ea840..bdc905572182df42d081ae3912b091e5458c757b 100644 (file)
@@ -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);