Index: usr.sbin/lpr/common_source/displayq.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/lpr/common_source/displayq.c,v retrieving revision 1.15.2.7 retrieving revision 1.15.2.8 diff -u -r1.15.2.7 -r1.15.2.8 --- usr.sbin/lpr/common_source/displayq.c 2001/07/29 23:06:27 1.15.2.7 +++ usr.sbin/lpr/common_source/displayq.c 2001/08/30 09:27:41 1.15.2.8 @@ -73,8 +73,8 @@ extern uid_t uid, euid; static int col; /* column on screen */ -static char current[40]; /* current file being printed */ -static char file[132]; /* print file name */ +static char current[MAXNAMLEN+1]; /* current file being printed */ +static char file[MAXNAMLEN+1]; /* print file name */ static int first; /* first file in ``files'' column? */ static int garbage; /* # of garbage cf files */ static int lflag; /* long output option */ @@ -95,7 +95,7 @@ { register struct jobqueue *q; register int i, nitems, fd, ret; - register char *cp; + char *cp, *endp; struct jobqueue **queue; struct stat statb; FILE *fp; @@ -156,8 +156,11 @@ else { /* get daemon pid */ cp = current; - while ((i = getc(fp)) != EOF && i != '\n') - *cp++ = i; + endp = cp + sizeof(current) - 1; + while ((i = getc(fp)) != EOF && i != '\n') { + if (cp < endp) + *cp++ = i; + } *cp = '\0'; i = atoi(current); if (i <= 0) { @@ -172,8 +175,11 @@ } else { /* read current file name */ cp = current; - while ((i = getc(fp)) != EOF && i != '\n') - *cp++ = i; + endp = cp + sizeof(current) - 1; + while ((i = getc(fp)) != EOF && i != '\n') { + if (cp < endp) + *cp++ = i; + } *cp = '\0'; /* * Print the status file.