Subject: bin/17471: Bug in lprm options parsing; update usage
To: None <>
From: None <>
List: netbsd-bugs
Date: 07/03/2002 15:18:58
>Number:         17471
>Category:       bin
>Synopsis:       Bug in lprm options parsing; update usage
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jul 03 13:20:01 PDT 2002
>Originator:     Brian Ginsbach
>Release:        NetBSD 1.5.2, current
Cray Inc.
System: NetBSD 1.5.2 NetBSD 1.5.2 (NBTEST) #1: Wed Feb 20 03:38:32 CST 2002 i386

	The error handling in the options parsing for lprm has a
	small bug.  When a negative wait time is given the error
	message has a "(null)" in place of the bad time.  The (null)
	should be the negative time from the command line.  The
	problem is that lprm does its own options parsing and does
	not use getopt(3).  The error message is passing optarg as
	the option string.  This is why the error message has the

	The patch below also updates the usage message to reflect
	current reality.

	# lprm -w -10
	lprm: wait time must be postive: (null)

Index: lprm.c
RCS file: /cvsroot/basesrc/usr.sbin/lpr/lprm/lprm.c,v
retrieving revision 1.10
diff -u -r1.10 lprm.c
--- lprm.c	1999/12/07 14:54:48	1.10
+++ lprm.c	2002/06/24 14:11:54
@@ -127,8 +127,8 @@
 					wait_time = atoi(*++argv);
 				if (wait_time < 0)
-					errx(1, "wait time must be postive: %s",
-					    optarg);
+					errx(1, "wait time must be postive: %d",
+					    wait_time);
 				if (wait_time < 30)
 				    warnx("warning: wait time less than 30 seconds");
@@ -164,6 +164,7 @@
 static void
-	fprintf(stderr, "usage: lprm [-] [-Pprinter] [[job #] [user] ...]\n");
+	fprintf(stderr,
+		"usage: lprm [-] [-Pprinter] [-w maxwait] [[job #] [user] ...]\n");