lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20240731085217.94928-1-michael.weiss@aisec.fraunhofer.de>
Date: Wed, 31 Jul 2024 10:52:17 +0200
From: Michael Weiß <michael.weiss@...ec.fraunhofer.de>
To: Ian Rogers <irogers@...gle.com>, Arnaldo Carvalho de Melo
	<acme@...hat.com>, Namhyung Kim <namhyung@...nel.org>
CC: <linux-kernel@...r.kernel.org>, <gyroidos@...ec.fraunhofer.de>,
	Michael Weiß <michael.weiss@...ec.fraunhofer.de>
Subject: [PATCH] tools lib subcmd: Fixed uninitialized use of variable in parse-options

Since commit ea558c86248b ("tools lib subcmd: Show parent options in
help"), our debug images fail to build.

For our Yocto-based GyroidOS, we build debug images with debugging enabled
for all binaries including the kernel. Yocto passes the corresponding gcc
option "-Og" also to the kernel HOSTCFLAGS. This results in the following
build error:

  parse-options.c: In function ‘options__order’:
  parse-options.c:834:9: error: ‘o’ may be used uninitialized [-Werror=maybe-uninitialized]
    834 |         memcpy(&ordered[nr_opts], o, sizeof(*o));
        |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  parse-options.c:812:30: note: ‘o’ was declared here
    812 |         const struct option *o, *p = opts;
        |                              ^
  ..

Fix it by initializing 'o' instead of 'p' in the above failing line 812.
'p' is initialized afterwards in the following for-loop anyway.
I think that was the intention of the commit ea558c86248b ("tools lib
subcmd: Show parent options in help") in the first place.

Fixes: ea558c86248b ("tools lib subcmd: Show parent options in help")
Signed-off-by: Michael Weiß <michael.weiss@...ec.fraunhofer.de>
---
 tools/lib/subcmd/parse-options.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/subcmd/parse-options.c b/tools/lib/subcmd/parse-options.c
index 4b60ec03b0bb..2a3b51a690c7 100644
--- a/tools/lib/subcmd/parse-options.c
+++ b/tools/lib/subcmd/parse-options.c
@@ -809,7 +809,7 @@ static int option__cmp(const void *va, const void *vb)
 static struct option *options__order(const struct option *opts)
 {
 	int nr_opts = 0, nr_group = 0, nr_parent = 0, len;
-	const struct option *o, *p = opts;
+	const struct option *o = opts, *p;
 	struct option *opt, *ordered = NULL, *group;
 
 	/* flatten the options that have parents */
-- 
2.39.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ