]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
dtls: added a null pointer check in record_overhead
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Fri, 22 Jul 2016 13:36:55 +0000 (15:36 +0200)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Fri, 22 Jul 2016 13:37:17 +0000 (15:37 +0200)
According to my reading this check is unnecessary as in
no case a null pointer can be encountered. However gcc6
warns about a null pointer derefence and thus adding it,
to be safe.

lib/dtls.c

index 31497183f30d9d0bf7b4fdc18424837d497eb420..50d5dcefc4b2cb9ad2eaeed1fc45573afb9d46cf 100644 (file)
@@ -500,6 +500,9 @@ static int record_overhead(const cipher_entry_st * cipher,
        int total = 0;
        int t, ret;
 
+       if (unlikely(cipher == NULL))
+               return 0;
+
        if (_gnutls_cipher_type(cipher) == CIPHER_BLOCK) {
                t = _gnutls_cipher_get_explicit_iv_size(cipher);
                total += t;
@@ -598,7 +601,6 @@ static int record_overhead_rt(gnutls_session_t session)
        if (ret < 0)
                return gnutls_assert_val(ret);
 
-       /* requires padding */
        return record_overhead(params->cipher, params->mac,
                               params->compression_algorithm);
 }