diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2021-09-22 09:14:39 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-10-01 15:28:49 +0200 |
commit | 66d5b73658545cced3e4978712d6963c93c25c80 (patch) | |
tree | 58265de21dd371739c0e3ff75d4db1d6713dd089 /common/startup.c | |
parent | 533a002abf8fd73ac5a8a73c42783c5120adb0d8 (diff) | |
download | barebox-66d5b73658545cced3e4978712d6963c93c25c80.tar.gz |
startup: don't read glob_t if glob("/env/init/*") fails
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 only freeing the glob_t if glob() had succeeded.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20210922071440.31949-1-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/startup.c')
-rw-r--r-- | common/startup.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/common/startup.c b/common/startup.c index d170cb8a7c..871696968a 100644 --- a/common/startup.c +++ b/common/startup.c @@ -345,9 +345,9 @@ static int run_init(void) run_command(scr); free(scr); } - } - globfree(&g); + globfree(&g); + } /* source matching script in /env/bmode/ */ bmode = reboot_mode_get(); |