From patchwork Fri Dec 4 06:57:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 552588 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 85EC614029C for ; Fri, 4 Dec 2015 18:07:36 +1100 (AEDT) Received: from localhost ([::1]:39085 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4kSs-0001bi-EZ for incoming@patchwork.ozlabs.org; Fri, 04 Dec 2015 02:07:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36581) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4kR8-0006T8-1o for qemu-devel@nongnu.org; Fri, 04 Dec 2015 02:05:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a4kR3-00049U-3X for qemu-devel@nongnu.org; Fri, 04 Dec 2015 02:05:45 -0500 Received: from isrv.corpit.ru ([86.62.121.231]:58314) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4kR2-00048l-SP; Fri, 04 Dec 2015 02:05:41 -0500 Received: from tsrv.tls.msk.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 0B64C4068B; Fri, 4 Dec 2015 10:05:38 +0300 (MSK) Received: from tls.msk.ru (mjt.vpn.tls.msk.ru [192.168.177.99]) by tsrv.tls.msk.ru (Postfix) with SMTP id 83F28AAF; Fri, 4 Dec 2015 09:57:43 +0300 (MSK) Received: (nullmailer pid 7961 invoked by uid 1000); Fri, 04 Dec 2015 06:57:42 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Date: Fri, 4 Dec 2015 09:57:35 +0300 Message-Id: <0e1d02452bf2c3486406dd48524a5b1de3c0eba8.1449211229.git.mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 86.62.121.231 Cc: qemu-trivial@nongnu.org, Michael Tokarev Subject: [Qemu-devel] [PULL 4/9] crypto: avoid two coverity false positive error reports X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: "Daniel P. Berrange" 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 Reviewed-by: Eric Blake Signed-off-by: Michael Tokarev --- crypto/tlscreds.c | 4 ++-- crypto/tlscredsx509.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/crypto/tlscreds.c b/crypto/tlscreds.c index 5ec982c..e7d9c1c 100644 --- a/crypto/tlscreds.c +++ b/crypto/tlscreds.c @@ -123,10 +123,10 @@ qcrypto_tls_creds_get_path(QCryptoTLSCreds *creds, goto cleanup; } - trace_qcrypto_tls_creds_get_path(creds, filename, - *cred ? *cred : ""); ret = 0; cleanup: + trace_qcrypto_tls_creds_get_path(creds, filename, + *cred ? *cred : ""); return ret; } diff --git a/crypto/tlscredsx509.c b/crypto/tlscredsx509.c index d080deb..26f18cb 100644 --- a/crypto/tlscredsx509.c +++ b/crypto/tlscredsx509.c @@ -255,6 +255,7 @@ qcrypto_tls_creds_check_cert_key_purpose(QCryptoTLSCredsX509 *creds, } g_free(buffer); + buffer = NULL; } if (isServer) {