[BusyBox] bug#1306: [PATCH INCLUDED] mknod.c does not create block or character devic es correctly

Stewart Brodie Stewart.Brodie at pace.co.uk
Mon Mar 31 09:16:03 UTC 2003


Package: busybox
Version: 0.61pre
Severity: high

coreutils/mknod.c revision 1.24 committed on 20th March 2003 does not create
block or character devices with the correct major or minor numbers.  This is
due to a bug in mknod.c described below, together with a small patch which
corrects the problem.

Due to an incorrect conditional expression, mknod only attempts to evaluate
the major and minor numbers if the node being created is NOT a block or
character device.  The result is that all character and block devices are
created with major and minor numbers of zero.  I believe that there is a
possibility of a seg fault when creating FIFOs due to evaluation of
non-existing parameters, but have not observed this is limited testing.


Index: coreutils/mknod.c
===================================================================
RCS file: /var/cvs/busybox/coreutils/mknod.c,v
retrieving revision 1.24
diff -b -w -u -r1.24 mknod.c
--- coreutils/mknod.c	19 Mar 2003 09:11:33 -0000	1.24
+++ coreutils/mknod.c	31 Mar 2003 14:02:47 -0000
@@ -46,7 +46,7 @@
 		mode |= modes_cubp[(int)(name[4])];
 
 		dev = 0;
-		if ((*name != 'p') && ((argc -= 2) == 0)) {
+		if ((*name != 'p') && ((argc -= 2) == 2)) {
 			dev = (bb_xgetularg10_bnd(argv[2], 0, 255) << 8)
 				+ bb_xgetularg10_bnd(argv[3], 0, 255);
 		}



More information about the busybox mailing list