mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <>
Cc: Ahmad Fatoum <>
Subject: [PATCH master 2/2] common: menutree: prevent read of uninitialized memory in error path
Date: Wed, 22 Sep 2021 09:14:40 +0200	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

globfree() is a no-op if glob_t::gl_pathv is NULL. A failed glob may not
always initialize this member however, leading to potential memory

Fix this by initializing glob_t.

Signed-off-by: Ahmad Fatoum <>
 common/menutree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/menutree.c b/common/menutree.c
index c28284b47a0c..9a14005ea209 100644
--- a/common/menutree.c
+++ b/common/menutree.c
@@ -84,7 +84,7 @@ int menutree(const char *path, int toplevel)
 	struct stat s;
 	char *box;
 	struct menutree *mt;
-	glob_t g;
+	glob_t g = {};
 	int i;
 	char *globpath, *display;
 	size_t size;

barebox mailing list

  reply	other threads:[~2021-09-22  7:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-22  7:14 [PATCH master 1/2] startup: don't read glob_t if glob("/env/init/*") fails Ahmad Fatoum
2021-09-22  7:14 ` Ahmad Fatoum [this message]
2021-10-01 13:29 ` Sascha Hauer

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:

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

  git send-email \ \ \ \

* 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