[comp.bugs.4bsd] lpr does not reject ``portable'' archive files. +Fix

gww@beatnix.UUCP (Gary Winiger) (03/13/88)

Subject: lpr does not reject ``portable'' archive files. +Fix
Index:	lpr/{lp.local.h, lpr.c} 4.3BSD +Fix

Description:
	Lpr will queue an archive file in the ``portable'' archive format
	for printing.
Repeat-By:
	lpr /lib/libc.a
Fix:
	Correctly recognize that the magic number of a portable archive
	is a string an is not 0177545.
	The procedure test in lpr.c attempts to validate the file being queued
	for printing.  In the case of a portable archive file, it does not
	do so correctly.  lp.local.h defines the magic numbers to be tested and
	defines the ``old'' format magic number for an archive file.  The
	portable archive magic number is really the string "!<arch>\n".
	The attached code solves this problem at Elxsi.

Gary..
{ucbvax!sun,lll-lcc!lll-tis,amdahl!altos86,bridge2}!elxsi!gww
--------- cut --------- snip --------- :.,$w diff -------------
Index: lp.local.h
*** /tmp/,RCSt1002598	Mon Oct 19 11:40:19 1987
--- lp.local.h	Mon Oct 19 11:31:29 1987
***************
*** 1,6 ****
! /*	$Header: lp.local.h,v 1.1 87/06/16 16:25:38 gww Exp $ ENIX BSD
   *
   * $Log:	lp.local.h,v $
   * Revision 1.1  87/06/16  16:25:38  gww
   * Initial revision
   * 
--- 1,9 ----
! /*	$Header: lp.local.h,v 1.2 87/10/19 11:31:02 gww Exp $ ENIX BSD
   *
   * $Log:	lp.local.h,v $
+  * Revision 1.2  87/10/19  11:31:02  gww
+  * Correctly recognize archive files.
+  * 
   * Revision 1.1  87/06/16  16:25:38  gww
   * Initial revision
   * 
***************
*** 26,36 ****
  #include <ar.h>
  
  #ifndef A_MAGIC1	/* must be a VM/UNIX system */
  #	define A_MAGIC1	OMAGIC
  #	define A_MAGIC2	NMAGIC
  #	define A_MAGIC3	ZMAGIC
- #	undef ARMAG
- #	define ARMAG	0177545
  #endif
  
  /*
Index: lpr.c
*** /tmp/,RCSt1002656	Mon Oct 19 11:44:10 1987
--- lpr.c	Mon Oct 19 11:38:38 1987
***************
*** 1,5 ****
--- 1,8 ----
  /*
   * $Log:	lpr.c,v $
+  * Revision 1.3  87/10/19  11:38:18  gww
+  * Correctly recognize archive files.
+  * 
   * Revision 1.2  87/10/19  11:22:39  gww
   * Add ``u'' option to call pr -f for formfeeds to separate pages.
   * 
***************
*** 20,26 ****
  #endif not lint
  
  #ifndef lint
! static char *ERcsId = "$Header: lpr.c,v 1.2 87/10/19 11:22:39 gww Exp $ ENIX BSD";
  static char sccsid[] = "@(#)lpr.c	5.2 (Berkeley) 11/17/85";
  #endif not lint
  
--- 23,29 ----
  #endif not lint
  
  #ifndef lint
! static char *ERcsId = "$Header: lpr.c,v 1.3 87/10/19 11:38:18 gww Locked $ ENIX BSD";
  static char sccsid[] = "@(#)lpr.c	5.2 (Berkeley) 11/17/85";
  #endif not lint
  
***************
*** 550,558 ****
  			printf("%s: %s is an executable program", name, file);
  			goto error1;
  
! 		case ARMAG:
! 			printf("%s: %s is an archive file", name, file);
! 			goto error1;
  		}
  	(void) close(fd);
  	if (rflag) {
--- 553,563 ----
  			printf("%s: %s is an executable program", name, file);
  			goto error1;
  
! 		default:
! 			if (strncmp((char *)&execb, ARMAG, SARMAG) == 0) {
! 				printf("%s: %s is an archive file", name, file);
! 				goto error1;
! 			}
  		}
  	(void) close(fd);
  	if (rflag) {

gwyn@brl-smoke.ARPA (Doug Gwyn ) (03/19/88)

In article <729@elxsi.UUCP> gww@beatnix.UUCP (Gary Winiger) writes:
>	Lpr will queue an archive file in the ``portable'' archive format
>	for printing.

Why should "lpr" try to be "smarter" than its invoker?
An archive file of sources contains entirely printable information
and there is no reason it should not be spoolable to a printer.

BRL's MDQS system will gladly spool anything anywhere, and that is
what I want a spooler to do.