From 4233a39933277b0d715d59d72942a8fd65bcec4a Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Fri, 24 Jan 2020 23:18:18 +0100 Subject: mtd-utils: Fix various TOCTOU issues This patch restructures various code parts that follow the pattern of "stat(x, &sb) ... makes_sense(&sb) ... open(x)". Signed-off-by: David Oberhollenzer --- jffsX-utils/mkfs.jffs2.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'jffsX-utils') diff --git a/jffsX-utils/mkfs.jffs2.c b/jffsX-utils/mkfs.jffs2.c index f46cc22..9cc5eaf 100644 --- a/jffsX-utils/mkfs.jffs2.c +++ b/jffsX-utils/mkfs.jffs2.c @@ -1772,9 +1772,7 @@ int main(int argc, char **argv) } out_fd = 1; } - if (lstat(rootdir, &sb)) { - sys_errmsg_die("%s", rootdir); - } + if (chdir(rootdir)) sys_errmsg_die("%s", rootdir); -- cgit v1.2.3