From nobody Sat Nov 15 10:54:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1752158716; cv=none; d=zohomail.com; s=zohoarc; b=U1Z64oyLYhxj1zvW+d6eRydbDm1QdPaYJCOE/FWJDT9URAT2m1V+CVrACF/U8IzVvVpUwRcYlPScGDpC+FqxFLIyqiS2ll04zx+/I+8lZsTb2vTeRP9z0vF+qZPf3ogiLzgo9BGcxe5EXmJW9+HKhPS6Kk71YM2LSVDdRG4Lo9w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752158716; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IwL1dqDOrIKJZCfzkxOD5rZXt7mV2IMgDmRaq3qIHsU=; b=OAL00RQgHx9YQPshgQ4+JNEjEBL0ntRPuLjdRy6iZM8g0p6QHuUbSY33cTY3ELPiBgagu0BN7yW3jVARXIeyUrBEoqSkoetIrqyt6g29SPyVSdDF8DF7IfWWloQ3AXmprPAeMUdEwREUbP4renRA46UYjPzQLhuUaKXSV+lIu6Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1752158716912992.3012970473959; Thu, 10 Jul 2025 07:45:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uZsVr-0003x2-Rm; Thu, 10 Jul 2025 10:44:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uZsVb-0003uj-Ts for qemu-devel@nongnu.org; Thu, 10 Jul 2025 10:44:24 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uZsVZ-0007mn-RP for qemu-devel@nongnu.org; Thu, 10 Jul 2025 10:44:23 -0400 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-3a582e09144so702911f8f.1 for ; Thu, 10 Jul 2025 07:44:21 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b5e8bd1833sm2010834f8f.8.2025.07.10.07.44.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Jul 2025 07:44:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1752158660; x=1752763460; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=IwL1dqDOrIKJZCfzkxOD5rZXt7mV2IMgDmRaq3qIHsU=; b=UAvS4UVMg2ZQyPSpT01Y8aJGI38+GSmrgtklDvGwyoQryxVHPc0WQ1sby+L0VfRD7b Vcyd90gWHByFRF39GbFJJgShlePut5AkMxE9hLCQhoI+uhzuaGT98LQfd9VO08XczjMd puPJGqEPgxfPy6U0pFikohfZK/osc5LXbVlxx5jNYZnkNsViFXh96e+pS/xI1ZS/VCj6 AbXZ25J5fns5OtLrEQ7M6YvE/lE2VuZHxabREvYXVRfV8LtCCbrWWh/r3Dqye4w/7Xbc OT6O4orzdxuz6SINvUOfA2IYIsb+XR0wn+C13Hl5wz7OtUGbqNndwqTD+Uv2zu0THJXh j1WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752158660; x=1752763460; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=IwL1dqDOrIKJZCfzkxOD5rZXt7mV2IMgDmRaq3qIHsU=; b=HO53oJkU37xVfknx6fMm4GE2/jakGq78Gzvw8M4QcdzoFP28E+m00NNMh86dJTXeCr XvgdZ+QLq1HUqN+gI9TUGFxxD+1yNnBIRe8kBbW79GNDGzSIyR7aU4lilcxwAhfeBr0r QmVFX3rVwEmMszAq5oXL1ZPNVsejS/hzPeAhFVphiQ1diPf3qpSRnsWP4sHrRwLGzHbP rWGpBsHtX3zv/anHBRUrItEMNXmcuZXOv2hz2IgaK2AJu8ivhJtL8MQABLPyiSI4yzMz QTAwhV9L7wV8DrciTf3PztlMGA6OouBRczUsfu3KOoeFjsE+gWxkN0rhW6MVfNWPCQHL rXAQ== X-Gm-Message-State: AOJu0YxjU154AeD+efheK4gkXrczhTq/3DaOX+SgmD8rxi2nHFHl9wXK CVo4JNedWTHYQ66eLg8+i8SlYFPTo5WK+tGYEUWQcKLKbGN8l9RJH3VZUEKW+9paNnFG+Gqx2gi 89NCX X-Gm-Gg: ASbGncusd0welP2ubLL5rOjkhD3c3b90A4fN9Ct1OTT+9p8biT7+wwV+U2fHCWzOjwy XDM/o7+AT552KfWc8tMjap31avvyuHSp8KIQuQzfHLSa9oBXgO6v5YJIqRsQHAm1MOJV8b8bEE5 kBu8gzNbxdqgz40CwqOocZLrqPlqCr1HHy3FVcQgfRsR2xYMg5WXWRxWygP9oOBQLdBd1V3O5pZ ff7mOm1zlnoYogQxBEdMTrEJrYlNmcTanjzrXAndyiFglYogurYYfZRqx6Ast1nEDel1FjXrm8O OSf3W+1vOsAsHfkXWzunZRqHzSD/JxjQN30+5uXDZvCBRD4ZKXr1DG5IpFRjr9cWwzdZ X-Google-Smtp-Source: AGHT+IGDZ2h6+RMKjEKd4y9rA9JQ479kJx7z7p/4v6g0i8r5OObhRTJ/GhM2W8v5jwOJWzmdwld7vA== X-Received: by 2002:a05:6000:41ce:b0:3a4:f7db:6ff7 with SMTP id ffacd0b85a97d-3b5e86e038cmr2890280f8f.52.1752158659796; Thu, 10 Jul 2025 07:44:19 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH] crypto/x509-utils: Check for error from gnutls_x509_crt_init() Date: Thu, 10 Jul 2025 15:44:17 +0100 Message-ID: <20250710144417.1187478-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1752158718134116600 Content-Type: text/plain; charset="utf-8" Coverity notes that in qcrypto_get_x509_cert_fingerprint() we call gnutls_x509_crt_init() but don't check for an error return. Add the missing check. Coverity: CID 1593155 Fixes: 10a1d34fc0d ("crypto: Introduce x509 utils") Signed-off-by: Peter Maydell Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- crypto/x509-utils.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crypto/x509-utils.c b/crypto/x509-utils.c index 8bad00a51b8..39bb6d4d8c3 100644 --- a/crypto/x509-utils.c +++ b/crypto/x509-utils.c @@ -46,7 +46,11 @@ int qcrypto_get_x509_cert_fingerprint(uint8_t *cert, siz= e_t size, return -1; } =20 - gnutls_x509_crt_init(&crt); + if (gnutls_x509_crt_init(&crt) < 0) { + error_setg(errp, "Unable to initialize certificate: %s", + gnutls_strerror(ret)); + return -1; + } =20 if (gnutls_x509_crt_import(crt, &datum, GNUTLS_X509_FMT_PEM) !=3D 0) { error_setg(errp, "Failed to import certificate"); --=20 2.43.0