public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Bastien Nocera <hadess@hadess.net>
To: linux-bluetooth@vger.kernel.org
Cc: Bastien Nocera <hadess@hadess.net>
Subject: [BlueZ 02/15] shared/ecc: Fix uninitialised variable usage
Date: Thu, 16 May 2024 11:03:06 +0200	[thread overview]
Message-ID: <20240516090340.61417-3-hadess@hadess.net> (raw)
In-Reply-To: <20240516090340.61417-1-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


  parent reply	other threads:[~2024-05-16  9:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-16  9:03 [BlueZ 00/15] Fix a number of static analysis issues #2 Bastien Nocera
2024-05-16  9:03 ` [BlueZ 01/15] main: Simplify variable assignment Bastien Nocera
2024-05-16  9:03 ` Bastien Nocera [this message]
2024-05-16  9:03 ` [BlueZ 03/15] shared/gatt-client: Fix uninitialised variable usage Bastien Nocera
2024-05-16  9:03 ` [BlueZ 04/15] tools/mesh-cfgclient: " Bastien Nocera
2024-05-16  9:03 ` [BlueZ 05/15] test-runner: Remove unused envp Bastien Nocera
2024-05-16  9:03 ` [BlueZ 06/15] test-runner: Fix uninitialised variable usage Bastien Nocera
2024-05-16  9:03 ` [BlueZ 07/15] " Bastien Nocera
2024-05-16  9:03 ` [BlueZ 08/15] shared/bap: Fix possible use-after-free Bastien Nocera
2024-05-16  9:03 ` [BlueZ 09/15] isotest: Fix bad free Bastien Nocera
2024-05-16  9:03 ` [BlueZ 10/15] test-runner: Fix fd leak on failure Bastien Nocera
2024-05-16  9:03 ` [BlueZ 11/15] isotest: Fix string size expectations Bastien Nocera
2024-05-16  9:03 ` [BlueZ 12/15] mgmt-tester: Fix non-nul-terminated string Bastien Nocera
2024-05-16  9:03 ` [BlueZ 13/15] gdbus: Check sprintf retval Bastien Nocera
2024-05-16  9:03 ` [BlueZ 14/15] shared/bap: Fix memory leak in error path Bastien Nocera
2024-05-16  9:03 ` [BlueZ 15/15] android/handsfree: Check sprintf retval Bastien Nocera
2024-05-16 20:50 ` [BlueZ 00/15] Fix a number of static analysis issues #2 patchwork-bot+bluetooth
2024-05-27  8:23   ` Bastien Nocera

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240516090340.61417-3-hadess@hadess.net \
    --to=hadess@hadess.net \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox