Subject: bin/3002: fsck tries to exec wrong backend
To: None <gnats-bugs@gnats.netbsd.org>
From: None <enami@ba2.so-net.or.jp>
List: netbsd-bugs
Date: 12/07/1996 20:30:43
>Number:         3002
>Category:       bin
>Synopsis:       fsck tries to exec wrong backend, eg, fsck_ffsffs.
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Dec  7 03:35:01 1996
>Last-Modified:
>Originator:     enami tsugutomo
>Organization:
	an individual
>Release:        NetBSD-current sup'ed on 1996 Dec 7 (GMT+9)
>Environment:
System: NetBSD pavlov.enami.ba2.so-net.or.jp 1.2B NetBSD 1.2B (PAVLOV) #123: Sat Dec 7 14:13:11 JST 1996 enami@pavlov.enami.ba2.so-net.or.jp:/b/netbsd/kernel/compile/PAVLOV i386


>Description:
	fsck tries to exec wrong backend, eg, fsck_ffsffs for ffs.  But there
	is no such backend.  As a result, system fails to boot.
>How-To-Repeat:
	Install fsck with sbin/fsck/fsck.c version 1.8 and run (or just
	reboot).
>Fix:
	The fsck.c version 1.8 apppeds backend filesystem name twice.
	It's wrong.  Here is my fix:
Index: fsck.c
===================================================================
RCS file: /a/cvsroot/NetBSD/sbin/fsck/fsck.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 fsck.c
--- fsck.c	1996/12/07 03:28:59	1.1.1.2
+++ fsck.c	1996/12/07 11:19:32
@@ -231,15 +231,11 @@
 	if (strcmp(vfstype, "ufs") == 0)
 		vfstype = MOUNT_UFS;
 
-	(void) snprintf(execbase, sizeof(execbase), "fsck_%s", vfstype);
-
 	maxargc = 100;
 	argv = emalloc(sizeof(char *) * maxargc);
 
 	/* construct basename of executable and argv[0] simultaneously */
-	(void)strncat(execbase,
-		     (const char *)vfstype,
-		     sizeof(execbase) - 6); /* strlen("fsck_") + \0 */ 
+	(void) snprintf(execbase, sizeof(execbase), "fsck_%s", vfstype);
 	argv[0] = vfstype;
 
 	if (options) {
>Audit-Trail:
>Unformatted: