Subject: bin/3256: mt blocksize 0 does not work
To: None <gnats-bugs@gnats.netbsd.org>
From: Juergen Hannken-Illjes <hannken@eis.cs.tu-bs.de>
List: netbsd-bugs
Date: 02/25/1997 11:26:12
>Number:         3256
>Category:       bin
>Synopsis:       mt blocksize 0 does not work
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Feb 25 02:35:01 1997
>Last-Modified:
>Originator:     Juergen Hannken-Illjes
>Organization:
Juergen Hannken-Illjes - hannken@eis.cs.tu-bs.de - TU Braunschweig (W Germany)
>Release:        <NetBSD-current source date>tar bals as of Feb 22, 1997
>Environment:
	
System: NetBSD watcher 1.2C NetBSD 1.2C (CUSTOM) #25: Mon Feb 17 22:43:01 MET 1997 hannken@watcher:/usr/src/sys/arch/sparc/compile/CUSTOM sparc


>Description:
	
It is not possible to set a tape to variable block size because
'mt blocksize 0' is invalid.
>How-To-Repeat:
	
mt blocksize 0
>Fix:
	

--- mt.c.orig	Tue Feb 25 11:08:18 1997
+++ mt.c	Tue Feb 25 11:20:48 1997
@@ -73,23 +73,24 @@
 	int c_code;
 	int c_ronly;
+	int c_mincount;
 };
 
 const struct commands com[] = {
-	{ "asf",	MTASF,  1 },
-	{ "blocksize",	MTSETBSIZ, 1 },
-	{ "bsf",	MTBSF,	1 },
-	{ "bsr",	MTBSR,	1 },
-	{ "density",	MTSETDNSTY, 1 },
-	{ "eof",	MTWEOF,	0 },
-	{ "eom",	MTEOM,	1 },
-	{ "erase",	MTERASE, 0 },
-	{ "fsf",	MTFSF,	1 },
-	{ "fsr",	MTFSR,	1 },
-	{ "offline",	MTOFFL,	1 },
-	{ "rewind",	MTREW,	1 },
-	{ "rewoffl",	MTOFFL,	1 },
-	{ "status",	MTNOP,	1 },
-	{ "retension",	MTRETEN, 1 },
-	{ "weof",	MTWEOF,	0 },
+	{ "asf",	MTASF,      1,  1 },
+	{ "blocksize",	MTSETBSIZ,  1,  0 },
+	{ "bsf",	MTBSF,      1,  1 },
+	{ "bsr",	MTBSR,      1,  1 },
+	{ "density",	MTSETDNSTY, 1,  1 },
+	{ "eof",	MTWEOF,     0,  1 },
+	{ "eom",	MTEOM,      1,  1 },
+	{ "erase",	MTERASE,    0,  1 },
+	{ "fsf",	MTFSF,      1,  1 },
+	{ "fsr",	MTFSR,      1,  1 },
+	{ "offline",	MTOFFL,     1,  1 },
+	{ "rewind",	MTREW,      1,  1 },
+	{ "rewoffl",	MTOFFL,     1,  1 },
+	{ "status",	MTNOP,      1,  1 },
+	{ "retension",	MTRETEN,    1,  1 },
+	{ "weof",	MTWEOF,     0,  1 },
 	{ NULL }
 };
@@ -169,8 +170,7 @@
 	} else if (comp->c_code != MTNOP) {
 
-		/* zero is *not* a valid count */
 		if (*argv) {
 			count = strtol(*argv, &p, 10);
-			if (count <= 0 || *p)
+			if (count < comp->c_mincount || *p)
 				errx(2, "%s: illegal count", *argv);
 		}
>Audit-Trail:
>Unformatted: