[PATCH master 2/2] common: menutree: prevent read of uninitialized memory in error path

Ahmad Fatoum a.fatoum at pengutronix.de
Wed Sep 22 00:14:40 PDT 2021


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
corruption.

Fix this by initializing glob_t.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 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;
-- 
2.30.2




More information about the barebox mailing list