1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
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.
|