From nobody Sun Apr 28 06:52:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1488203201536975.7796261846702; Mon, 27 Feb 2017 05:46:41 -0800 (PST) Received: from localhost ([::1]:52914 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLdQ-0004gw-3E for importer@patchew.org; Mon, 27 Feb 2017 08:46:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52283) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLWa-00075P-TU for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:39:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciLWZ-0000S9-RW for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:39:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56238) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciLWZ-0000S4-LX for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:39:35 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9E47F12B24; Mon, 27 Feb 2017 13:39:35 +0000 (UTC) Received: from t460.redhat.com (ovpn-117-152.ams2.redhat.com [10.36.117.152]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1RDdUsB014148; Mon, 27 Feb 2017 08:39:33 -0500 From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 13:39:26 +0000 Message-Id: <20170227133927.759-2-berrange@redhat.com> In-Reply-To: <20170227133927.759-1-berrange@redhat.com> References: <20170227133927.759-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 27 Feb 2017 13:39:35 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v1 1/2] crypto: fix leak in ivgen essiv init X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Li Qiang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Li Qiang On error path, the 'salt' doesn't been freed thus leading a memory leak. This patch avoid this. Signed-off-by: Li Qiang Signed-off-by: Daniel P. Berrange --- crypto/ivgen-essiv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/crypto/ivgen-essiv.c b/crypto/ivgen-essiv.c index 634de63..cba20bd 100644 --- a/crypto/ivgen-essiv.c +++ b/crypto/ivgen-essiv.c @@ -48,6 +48,7 @@ static int qcrypto_ivgen_essiv_init(QCryptoIVGen *ivgen, &salt, &nhash, errp) < 0) { g_free(essiv); + g_free(salt); return -1; } =20 --=20 2.9.3 From nobody Sun Apr 28 06:52:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1488204481556509.970135414806; Mon, 27 Feb 2017 06:08:01 -0800 (PST) Received: from localhost ([::1]:53025 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLy4-0006Q0-5t for importer@patchew.org; Mon, 27 Feb 2017 09:08:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciLWc-00077D-N0 for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:39:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciLWb-0000Sj-Nz for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:39:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48118) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciLWb-0000SW-HU for qemu-devel@nongnu.org; Mon, 27 Feb 2017 08:39:37 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A8ABD81129; Mon, 27 Feb 2017 13:39:37 +0000 (UTC) Received: from t460.redhat.com (ovpn-117-152.ams2.redhat.com [10.36.117.152]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1RDdUsC014148; Mon, 27 Feb 2017 08:39:36 -0500 From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 13:39:27 +0000 Message-Id: <20170227133927.759-3-berrange@redhat.com> In-Reply-To: <20170227133927.759-1-berrange@redhat.com> References: <20170227133927.759-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 27 Feb 2017 13:39:37 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v1 2/2] crypto: assert cipher algorithm is always valid X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Prasad J Pandit Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Prasad J Pandit Crypto routines 'qcrypto_cipher_get_block_len' and 'qcrypto_cipher_get_key_len' return non-zero cipher block and key lengths from static arrays 'alg_block_len[]' and 'alg_key_len[]' respectively. Returning 'zero(0)' value from either of them would likely lead to an error condition. Signed-off-by: Prasad J Pandit Signed-off-by: Daniel P. Berrange --- crypto/cipher.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/crypto/cipher.c b/crypto/cipher.c index 9ecaff7..5a96489 100644 --- a/crypto/cipher.c +++ b/crypto/cipher.c @@ -63,18 +63,14 @@ static bool mode_need_iv[QCRYPTO_CIPHER_MODE__MAX] =3D { =20 size_t qcrypto_cipher_get_block_len(QCryptoCipherAlgorithm alg) { - if (alg >=3D G_N_ELEMENTS(alg_key_len)) { - return 0; - } + assert(alg < G_N_ELEMENTS(alg_key_len)); return alg_block_len[alg]; } =20 =20 size_t qcrypto_cipher_get_key_len(QCryptoCipherAlgorithm alg) { - if (alg >=3D G_N_ELEMENTS(alg_key_len)) { - return 0; - } + assert(alg < G_N_ELEMENTS(alg_key_len)); return alg_key_len[alg]; } =20 --=20 2.9.3