Path: utzoo!mnetor!uunet!husc6!tut.cis.ohio-state.edu!mailrus!nrl-cmf!ames!lll-tis!elxsi!beatnix!gww From: gww@beatnix.UUCP (Gary Winiger) Newsgroups: comp.bugs.4bsd Subject: lpr does not reject ``portable'' archive files. +Fix Message-ID: <729@elxsi.UUCP> Date: 12 Mar 88 20:14:48 GMT Sender: nobody@elxsi.UUCP Reply-To: gww@beatnix.UUCP (Gary Winiger) Organization: ELXSI Super Computers, San Jose Lines: 110 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 "!\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 #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) {