Index: usr.sbin/lpr/common_source/displayq.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/lpr/common_source/displayq.c,v
retrieving revision 1.14.2.1
retrieving revision 1.14.2.2
diff -u -r1.14.2.1 -r1.14.2.2
--- usr.sbin/lpr/common_source/displayq.c	1999/08/29 15:43:08	1.14.2.1
+++ usr.sbin/lpr/common_source/displayq.c	2001/08/30 09:46:44	1.14.2.2
@@ -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 */
@@ -97,7 +97,7 @@
 {
 	register struct queue *q;
 	register int i, nitems, fd, ret;
-	register char	*cp;
+	char *cp, *endp;
 	struct queue **queue;
 	struct stat statb;
 	FILE *fp;
@@ -158,8 +158,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) {
@@ -174,8 +177,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.
