crypto: avoid two coverity false positive error reports
authorDaniel P. Berrange <berrange@redhat.com>
Fri, 13 Nov 2015 17:45:27 +0000 (17:45 +0000)
committerMichael Tokarev <mjt@tls.msk.ru>
Fri, 4 Dec 2015 06:39:55 +0000 (09:39 +0300)
In qcrypto_tls_creds_get_path() coverity complains that
we are checking '*creds' for NULL, despite having
dereferenced it previously. This is harmless bug due
to fact that the trace call was too early. Moving it
after the cleanup gets the desired semantics.

In qcrypto_tls_creds_check_cert_key_purpose() coverity
complains that we're passing a pointer to a previously
free'd buffer into gnutls_x509_crt_get_key_purpose_oid()
This is harmless because we're passing a size == 0, so
gnutls won't access the buffer, but rather just report
what size it needs to be. We can avoid it though by
explicitly setting the buffer to NULL after free'ing
it.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
crypto/tlscreds.c
crypto/tlscredsx509.c

index 5ec982c6ee5ca016d2d538f7f87d2a2b81006c44..e7d9c1cfac8aae75fa13d462ba5191022386391e 100644 (file)
@@ -123,10 +123,10 @@ qcrypto_tls_creds_get_path(QCryptoTLSCreds *creds,
         goto cleanup;
     }
 
-    trace_qcrypto_tls_creds_get_path(creds, filename,
-                                     *cred ? *cred : "<none>");
     ret = 0;
  cleanup:
+    trace_qcrypto_tls_creds_get_path(creds, filename,
+                                     *cred ? *cred : "<none>");
     return ret;
 }
 
index d080deb83e76aee512de78c32a429d53c6b7d0ce..26f18cbb4ab4b48afeab109bbf73d6c1f7e15ea0 100644 (file)
@@ -255,6 +255,7 @@ qcrypto_tls_creds_check_cert_key_purpose(QCryptoTLSCredsX509 *creds,
         }
 
         g_free(buffer);
+        buffer = NULL;
     }
 
     if (isServer) {