Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 May 1997 10:00:07 +0200 (CEST)
From:      lbnstn@lili.uni-bielefeld.de
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   bin/3556: Bug with -i option in /usr/bin/lpr
Message-ID:  <199705090800.KAA00378@lili23.lili.uni-bielefeld.de>
Resent-Message-ID: <199705090810.BAA19799@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         3556
>Category:       bin
>Synopsis:       Bug with -i option in /usr/bin/lpr
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri May  9 01:10:01 PDT 1997
>Last-Modified:
>Originator:     Uwe Laubenstein
>Organization:
Universitaet Bielefeld, Germany
>Release:        FreeBSD 2.2.1-RELEASE i386
>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 */
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199705090800.KAA00378>