NetBSD Problem Report #58759
From www@netbsd.org Fri Oct 18 11:19:53 2024
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
client-signature RSA-PSS (2048 bits) client-digest SHA256)
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 7B4C71A923D
for <gnats-bugs@gnats.NetBSD.org>; Fri, 18 Oct 2024 11:19:53 +0000 (UTC)
Message-Id: <20241018111951.D46AD1A923E@mollari.NetBSD.org>
Date: Fri, 18 Oct 2024 11:19:51 +0000 (UTC)
From: hashimoto.kenichi.0615@gmail.com
Reply-To: hashimoto.kenichi.0615@gmail.com
To: gnats-bugs@NetBSD.org
Subject: makefs: faild to merging with extra-directory using -r option
X-Send-Pr-Version: www-1.0
>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: needs-pullups
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Oct 18 11:20:00 +0000 2024
>Closed-Date:
>Last-Modified: Mon Feb 23 05:34:54 +0000 2026
>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;
+ }
}
}
}
===================================================================
>Release-Note:
>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/58759 CVS commit: src/usr.sbin/makefs
Date: Fri, 18 Oct 2024 19:28:03 -0400
Module Name: src
Committed By: christos
Date: Fri Oct 18 23:28:03 UTC 2024
Modified Files:
src/usr.sbin/makefs: walk.c
Log Message:
PR/58759: Kenichi Hashimoto: failed merge with extra-directory using -r option
To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/usr.sbin/makefs/walk.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->needs-pullups
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Mon, 23 Feb 2026 05:34:54 +0000
State-Changed-Why:
fixed in HEAD and 11, needs pullup-10 and pullup-9
also needs an automatic test
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.