Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp153143lqo; Thu, 16 May 2024 02:07:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUwEyxTIQt+fVDUoZMLy3P1WIR9iJ/gBRRL87Pm4+DJWr61iB+k+dArAeEnBKP0Km/N17LAfJYtkq9mTRsnZko2grfP1bU5ig9wrQkyjQ== X-Google-Smtp-Source: AGHT+IG32pwwM3AQMiUt9AsjJsh6vpuH8jc8iBE47aaTxsPowNddKtPo9gP8Ar61vWulFeeuAgyo X-Received: by 2002:a05:6e02:1cac:b0:36c:5154:8ce4 with SMTP id e9e14a558f8ab-36cc1503128mr203818265ab.30.1715850440768; Thu, 16 May 2024 02:07:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715850440; cv=pass; d=google.com; s=arc-20160816; b=VvvWW6xCIMALWzfR8Rr1pXKkFbCWhSSCRKQ1MDJMuJhsYOgmhmWOXYXrgBlykvzBTE DxY8xvan6aJLLBkbcmtFfPlRKH4fWiXNejtquAHgE5d1XfYXqBg1Nh4TOJ6BqTHoGkUp l6bdyKM46867yuvGioN86WpB4WEol/VMOUXUuMoMIz68YfcK8dbso0RnyyFfe9Hx1udc hckkY4pKtC6Jrg8MQH9aYLEb2pT6HfAJpR9gFHyOO/23r/WDwPfgU5cfAim1GWtpaT1L qvqEDPTx+EHj7UFPSPmtHXPk9RDm1gcyfoX2W1kWIXA922rxNBWpBO8fFMjl1Fn694rQ Me/Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=417fEdwr1mLglsViq792m2RUSfKTTYbpeukfrCSX+zU=; fh=uo5u2TQK/HQlhydMwGLjBAnuDwaLxndJ/cgWTjIagS8=; b=mwwX9dKXicZ4Y5K9y9Q6+8K4FXXabwALySOMVAFuR3utCiRSUomCPbONLOe2Z5CdyI 2y8XpRyzhtVX4/0swAUjko1sgeR6opEaNQTU5AugR9J1XeuD6ot+DLbyEBpqfOlPT2N6 5ngfXFOWT8xClA5wLmGDDpAzQUKar8EOnu9KjvOMapI4G8Q8m/OhXRFcKi6Fg0hhaPvH A75UOD/VlIgIZE17/POtjvPo5Nrn3zE28SIvMBLvts4TvoqXNiEu4byS9WTngCF5ufDY W5kXdpbWT8wgB7As6EJWcIUlJJk0UUwYJyrBVSWy/DU/ujdd5eMtWiNNhPdzZhbsXUfD zy1A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=hadess.net); spf=pass (google.com: domain of linux-bluetooth+bounces-4685-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4685-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6340a06d73csi17157538a12.129.2024.05.16.02.07.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 02:07:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-4685-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=hadess.net); spf=pass (google.com: domain of linux-bluetooth+bounces-4685-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4685-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 93363B234C1 for ; Thu, 16 May 2024 09:04:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 54A0C143737; Thu, 16 May 2024 09:03:50 +0000 (UTC) X-Original-To: linux-bluetooth@vger.kernel.org Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 329AF142E98 for ; Thu, 16 May 2024 09:03:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.197 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715850230; cv=none; b=p9HJhzI/Cj++6qXlB+VGfs+azpsTUgq+eIWYToLWhp5qD2HHdbDHFaUuFZ7dsysmkDh/1WnOKvTfC4GFhj2IMYzJ06K9zAaYzzZ/DRo9OppcnOZBhx471sDQCJ6glWu1bjJXwvK8aPKtuKnhx/UXTR6iuSO7mqMLMUZ0Pa3ZIrQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715850230; c=relaxed/simple; bh=775yw1FtGK63PePq+QzcMwFpusP36M4cfJGURqF/dsY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YScOLhPNtL8USKb3CkNmXVUV/EqZwITfR7Y1jaLdeAXkbCrGIZdsnf4BkcnyWWQWI2jBItNJBj7uh8MRnf9MrvcCsY4asoQY0y7a0klNOhGHPynW/FnAv4NHVSfQQugSh18pokyiw3DqiXw2LgwoCA2yUHmRpUEnyM1ntQ2jTFc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hadess.net; spf=pass smtp.mailfrom=hadess.net; arc=none smtp.client-ip=217.70.183.197 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hadess.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hadess.net Received: by mail.gandi.net (Postfix) with ESMTPSA id 90A491C0009; Thu, 16 May 2024 09:03:41 +0000 (UTC) From: Bastien Nocera To: linux-bluetooth@vger.kernel.org Cc: Bastien Nocera Subject: [BlueZ 02/15] shared/ecc: Fix uninitialised variable usage Date: Thu, 16 May 2024 11:03:06 +0200 Message-ID: <20240516090340.61417-3-hadess@hadess.net> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240516090340.61417-1-hadess@hadess.net> References: <20240516090340.61417-1-hadess@hadess.net> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: hadess@hadess.net Error: UNINIT (CWE-457): [#def41] [important] bluez-5.75/src/shared/ecc.c:869:2: var_decl: Declaring variable "pk" without initializer. bluez-5.75/src/shared/ecc.c:885:34: uninit_use_in_call: Using uninitialized element of array "pk.x" when calling "ecc_point_is_zero". 883| 884| ecc_point_mult(&pk, &curve_g, priv, NULL, vli_num_bits(priv)); 885|-> } while (ecc_point_is_zero(&pk)); 886| 887| ecc_native2bytes(priv, private_key); Error: UNINIT (CWE-457): [#def42] [important] bluez-5.75/src/shared/ecc.c:869:2: var_decl: Declaring variable "pk" without initializer. bluez-5.75/src/shared/ecc.c:885:34: uninit_use_in_call: Using uninitialized element of array "pk.x" when calling "ecc_point_is_zero". bluez-5.75/src/shared/ecc.c:885:34: uninit_use_in_call: Using uninitialized element of array "pk.y" when calling "ecc_point_is_zero". 883| 884| ecc_point_mult(&pk, &curve_g, priv, NULL, vli_num_bits(priv)); 885|-> } while (ecc_point_is_zero(&pk)); 886| 887| ecc_native2bytes(priv, private_key); Error: UNINIT (CWE-457): [#def43] [important] bluez-5.75/src/shared/ecc.c:869:2: var_decl: Declaring variable "pk" without initializer. bluez-5.75/src/shared/ecc.c:889:2: uninit_use_in_call: Using uninitialized value "*pk.y" when calling "ecc_native2bytes". 887| ecc_native2bytes(priv, private_key); 888| ecc_native2bytes(pk.x, public_key); 889|-> ecc_native2bytes(pk.y, &public_key[32]); 890| 891| return true; --- src/shared/ecc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/shared/ecc.c b/src/shared/ecc.c index adaae2082e1f..02bccbd430f6 100644 --- a/src/shared/ecc.c +++ b/src/shared/ecc.c @@ -870,6 +870,8 @@ bool ecc_make_key(uint8_t public_key[64], uint8_t private_key[32]) uint64_t priv[NUM_ECC_DIGITS]; unsigned int tries = 0; + memset(&pk, 0, sizeof(pk)); + do { if (!get_random_number(priv) || (tries++ >= MAX_TRIES)) return false; -- 2.44.0