From lbnstn@lili23.lili.uni-bielefeld.de  Fri May  9 01:00:14 1997
Received: from lili23.lili.uni-bielefeld.de (lili23.lili.uni-bielefeld.de [129.70.23.23])
          by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id BAA19330
          for <FreeBSD-gnats-submit@freebsd.org>; Fri, 9 May 1997 01:00:09 -0700 (PDT)
Received: (from lbnstn@localhost)
	by lili23.lili.uni-bielefeld.de (8.8.5/8.8.5) id KAA00378;
	Fri, 9 May 1997 10:00:07 +0200 (CEST)
Message-Id: <199705090800.KAA00378@lili23.lili.uni-bielefeld.de>
Date: Fri, 9 May 1997 10:00:07 +0200 (CEST)
From: lbnstn@lili.uni-bielefeld.de
Reply-To: lbnstn@lili.uni-bielefeld.de
To: FreeBSD-gnats-submit@freebsd.org
Subject: Bug with -i option in /usr/bin/lpr
X-Send-Pr-Version: 3.2

>Number:         3557
>Category:       bin
>Synopsis:       Bug with -i option in /usr/bin/lpr
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri May  9 01:10:03 PDT 1997
>Closed-Date:    Sat May 10 02:15:45 PDT 1997
>Last-Modified:  Sat May 10 02:16:08 PDT 1997
>Originator:     Uwe Laubenstein
>Release:        FreeBSD 2.2.1-RELEASE i386
>Organization:
Universitaet Bielefeld, Germany
>Environment:

	

>Description:

There seems to be a bug in /usr/bin/lpr:
If lpr is invoked with -i but no argument to -i is supplied, then
then getopt eats up the argument following -i.
The bug is present in "FreeBSD 2.2-970422-RELENG" and "FreeBSD 2.2.1-RELEASE"

>How-To-Repeat:

	lpr -i /etc/motd		# hangs
	lpr -i -p /etc/motd		# ignores -p

>Fix:

*** /usr/src/usr.sbin/lpr/lpr/lpr.c.orig	Wed Feb 26 03:31:53 1997
--- /usr/src/usr.sbin/lpr/lpr/lpr.c	Thu May  8 12:08:12 1997
***************
*** 74,79 ****
--- 74,81 ----
  #include "lp.local.h"
  #include "pathnames.h"
  
+ extern int	optreset;
+ 
  static char	*cfname;	/* daemon control files, linked from tf's */
  static char	*class = host;	/* class title on header page */
  static char	*dfname;	/* data files */
***************
*** 121,127 ****
  	struct passwd *pw;
  	struct group *gptr;
  	register char *arg, *cp;
! 	char buf[BUFSIZ];
  	int c, i, f, errs;
  	struct stat stb;
  
--- 123,129 ----
  	struct passwd *pw;
  	struct group *gptr;
  	register char *arg, *cp;
! 	char *p, buf[BUFSIZ];
  	int c, i, f, errs;
  	struct stat stb;
  
***************
*** 198,204 ****
  
  		case 'i':		/* indent output */
  			iflag++;
! 			indent = atoi(optarg);
  			break;
  
  		case 'm':		/* send mail when done */
--- 200,214 ----
  
  		case 'i':		/* indent output */
  			iflag++;
! 			indent = strtol (optarg, &p, 10);
! 			/* if optarg is not a valid number we assume	*/
! 			/* it is another option or a filename		*/
! 			if (*p != '\0')
! 			{
! 				indent = 8;
! 				optreset = 1;
! 				optind--;
! 			}
  			break;
  
  		case 'm':		/* send mail when done */
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: jmg 
State-Changed-When: Sat May 10 02:15:45 PDT 1997 
State-Changed-Why:  
duplicate of 3556. 
How did you submit this pr? 
>Unformatted:
