From a916fc7aa3cb9f784ecf97ee690e8fe28acf887b Mon Sep 17 00:00:00 2001 From: Zak Estrada Date: Thu, 12 Jan 2023 13:44:36 -0500 Subject: [PATCH] Skip device if parent is a file and not a dir --- genext2fs.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/genext2fs.c b/genext2fs.c index 96bbb43..a1e5233 100644 --- a/genext2fs.c +++ b/genext2fs.c @@ -2629,6 +2629,8 @@ add2fs_from_file(filesystem *fs, uint32 this_nod, FILE * fh, uint32 fs_timestamp size_t len; struct stat st; int nbargs, lineno = 0; + nod_info *ni; + inode *pnode; fstat(fileno(fh), &st); ctime = fs_timestamp; @@ -2684,6 +2686,14 @@ add2fs_from_file(filesystem *fs, uint32 this_nod, FILE * fh, uint32 fs_timestamp { error_msg("device table line %d skipped: can't find directory '%s' to create '%s''", lineno, dir, name); continue; + } else { + pnode = get_nod(fs, nod, &ni); + if((pnode->i_mode & FM_IFMT) != FM_IFDIR) { + error_msg("device table line %d skipped: parent '%s' is not a directory so won't create '%s''", lineno, dir, name); + put_nod(ni); + continue; + } + put_nod(ni); } } else