Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!nbires!hao!hplabs!utah-cs!reading From: reading@utah-cs.UUCP (Dan L. Reading) Newsgroups: comp.bugs.4bsd Subject: Bug in lpd Message-ID: <4201@utah-cs.UUCP> Date: Thu, 22-Jan-87 12:54:29 EST Article-I.D.: utah-cs.4201 Posted: Thu Jan 22 12:54:29 1987 Date-Received: Fri, 23-Jan-87 06:42:28 EST Organization: University of Utah CS Dept Lines: 90 There is a bug in lpd such that if you increase the 'pw' entry in printcap to > 132, lpd will core dump when it tries to print the banner page and the name of the file is longer then 10 chars. This is because the size of the internal buffer used while printing the block chars is set by LINELEN, but the amount to put into the is set by PW. A fix would be to change the routine scan_out() in ~/usr.lib/lpr/printjob.c, to use "PW" to set the internal buffer size instead of using the #define LINELEN. Since LINELEN is only used in this one case it can be deleted from the .h file. =============================================================================== RCS file: RCS/printjob.c,v retrieving revision 3.7 diff -c -r3.7 printjob.c *** /tmp/,RCSt1005890 Thu Jan 22 10:07:45 1987 --- printjob.c Thu Jan 22 09:34:00 1987 *************** *** 975,986 **** { register char *strp; register nchrs, j; ! char outbuf[LINELEN+1], *sp, c, cc; int d, scnhgt; extern char scnkey[][HEIGHT]; /* in lpdchar.c */ for (scnhgt = 0; scnhgt++ < HEIGHT+DROP; ) { ! strp = &outbuf[0]; sp = scsp; for (nchrs = 0; ; ) { d = dropit(c = TRC(cc = *sp++)); --- 975,988 ---- { register char *strp; register nchrs, j; ! char *outbuf, *sp, c, cc; int d, scnhgt; extern char scnkey[][HEIGHT]; /* in lpdchar.c */ + outbuf = malloc(PW+1); + for (scnhgt = 0; scnhgt++ < HEIGHT+DROP; ) { ! strp = outbuf; sp = scsp; for (nchrs = 0; ; ) { d = dropit(c = TRC(cc = *sp++)); *************** *** 1000,1005 **** --- 1002,1008 ---- *strp++ = '\n'; (void) write(scfd, outbuf, strp-outbuf); } + free(outbuf); } dropit(c) =============================================================================== RCS file: RCS/lp.local.h,v retrieving revision 1.2 diff -c -r1.2 lp.local.h *** /tmp/,RCSt1005906 Thu Jan 22 10:08:08 1987 --- lp.local.h Thu Jan 22 09:36:45 1987 *************** *** 53,62 **** #define FILMOD 0660 /* ! * Printer is assumed to support LINELEN (for block chars) ! * and background character (blank) is a space */ - #define LINELEN 132 #define BACKGND ' ' #define HEIGHT 9 /* height of characters */ --- 53,60 ---- #define FILMOD 0660 /* ! * Background character (blank) (for block chars) is a space */ #define BACKGND ' ' #define HEIGHT 9 /* height of characters */ ===============================================================================