NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
toolchain/58759: makefs: faild to merging with extra-directory using -r option
>Number: 58759
>Category: toolchain
>Synopsis: makefs: faild to merging with extra-directory using -r option
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: toolchain-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Oct 18 11:20:00 +0000 2024
>Originator: Kenichi Hashimoto
>Release: NetBSD 9.99.37
>Organization:
Genetec Corporation
>Environment:
NetBSD VM-Hashimoto 9.99.37 NetBSD 9.99.37 (GENERIC) #18: Thu Mar 26 10:59:06 JST 2020 root@VM-Hashimoto:/usr/obj/sys/arch/amd64/compile/GENERIC amd64
>Description:
There is a bug in makefs when using the -r option with the extra-directory merge process.
If a directory contains only one file, merging causes that file to become a 0-byte file.
For example, when creating an installation image and trying to overwrite
/var/cron/tabs/root
the operation fails, and the file is reduced to 0 bytes.
>How-To-Repeat:
1. Use makefs with the -r option and specify an extra-directory.
2. Ensure the directory being merged contains only one file.
3. bserve that after merging, the file becomes a 0-byte file instead of retaining its original content.
>Fix:
===================================================================
diff --git a/usr.sbin/makefs/walk.c b/usr.sbin/makefs/walk.c
index 77a75cf4a50d..b83981757755 100644
--- a/usr.sbin/makefs/walk.c
+++ b/usr.sbin/makefs/walk.c
@@ -177,7 +177,16 @@ walk_dir(const char *root, const char *dir, fsnode *parent, fsnode *join,
continue;
p->next = cur->next;
}
+ free(cur->path);
+ free(cur->name);
free(cur);
+
+ if (prev == cur) {
+ cur = join;
+ while (cur->next != NULL)
+ cur = cur->next;
+ prev = cur;
+ }
}
}
}
===================================================================
Home |
Main Index |
Thread Index |
Old Index