summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/lpr/common_source/displayq.c7
-rw-r--r--usr.sbin/lpr/lpc/cmds.c10
-rw-r--r--usr.sbin/lpr/lpd/lpd.c7
-rw-r--r--usr.sbin/lpr/lpd/printjob.c31
-rw-r--r--usr.sbin/lpr/lpd/recvjob.c13
5 files changed, 26 insertions, 42 deletions
diff --git a/usr.sbin/lpr/common_source/displayq.c b/usr.sbin/lpr/common_source/displayq.c
index efb9301f554..6524a759d39 100644
--- a/usr.sbin/lpr/common_source/displayq.c
+++ b/usr.sbin/lpr/common_source/displayq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: displayq.c,v 1.10 1998/06/23 22:40:34 millert Exp $ */
+/* $OpenBSD: displayq.c,v 1.11 2001/06/22 15:27:19 lebel Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)displayq.c 8.4 (Berkeley) 4/28/95";
#else
-static char rcsid[] = "$OpenBSD: displayq.c,v 1.10 1998/06/23 22:40:34 millert Exp $";
+static char rcsid[] = "$OpenBSD: displayq.c,v 1.11 2001/06/22 15:27:19 lebel Exp $";
#endif
#endif /* not lint */
@@ -340,8 +340,7 @@ inform(cf)
if (line[0] < 'a' || line[0] > 'z')
continue;
if (j == 0 || strcmp(file, line+1) != 0) {
- (void) strncpy(file, line+1, sizeof(file) - 1);
- file[sizeof(file) - 1] = '\0';
+ (void) strlcpy(file, line+1, sizeof(file));
}
j++;
continue;
diff --git a/usr.sbin/lpr/lpc/cmds.c b/usr.sbin/lpr/lpc/cmds.c
index d1c66e1a7f3..8c04c7d4dcb 100644
--- a/usr.sbin/lpr/lpc/cmds.c
+++ b/usr.sbin/lpr/lpc/cmds.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmds.c,v 1.10 2000/11/21 07:22:53 deraadt Exp $ */
+/* $OpenBSD: cmds.c,v 1.11 2001/06/22 15:27:20 lebel Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)cmds.c 8.2 (Berkeley) 4/28/95";
#else
-static char rcsid[] = "$OpenBSD: cmds.c,v 1.10 2000/11/21 07:22:53 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: cmds.c,v 1.11 2001/06/22 15:27:20 lebel Exp $";
#endif
#endif /* not lint */
@@ -347,8 +347,7 @@ cleanpr()
n++;
}
if (n == 0) {
- strncpy(lp, cp, sizeof(line) - strlen(line) - 1);
- line[sizeof(line) - 1] = '\0';
+ strlcpy(lp, cp, sizeof(line) - strlen(line));
unlinkf(line);
}
} else {
@@ -357,8 +356,7 @@ cleanpr()
* been skipped above) or a tf file (which can always
* be removed).
*/
- strncpy(lp, cp, sizeof(line) - strlen(line) - 1);
- line[sizeof(line) - 1] = '\0';
+ strlcpy(lp, cp, sizeof(line) - strlen(line));
unlinkf(line);
}
} while (++i < nitems);
diff --git a/usr.sbin/lpr/lpd/lpd.c b/usr.sbin/lpr/lpd/lpd.c
index 42befc9a1c2..e7e22ef26ef 100644
--- a/usr.sbin/lpr/lpd/lpd.c
+++ b/usr.sbin/lpr/lpd/lpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lpd.c,v 1.16 1998/08/03 16:53:16 millert Exp $ */
+/* $OpenBSD: lpd.c,v 1.17 2001/06/22 15:27:20 lebel Exp $ */
/* $NetBSD: lpd.c,v 1.7 1996/04/24 14:54:06 mrg Exp $ */
/*
@@ -45,7 +45,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)lpd.c 8.7 (Berkeley) 5/10/95";
#else
-static char rcsid[] = "$OpenBSD: lpd.c,v 1.16 1998/08/03 16:53:16 millert Exp $";
+static char rcsid[] = "$OpenBSD: lpd.c,v 1.17 2001/06/22 15:27:20 lebel Exp $";
#endif
#endif /* not lint */
@@ -533,8 +533,7 @@ chkhost(f)
fatal("Host name for your address (%s) unknown",
inet_ntoa(f->sin_addr));
- (void) strncpy(fromb, hp->h_name, sizeof(fromb)-1);
- from[sizeof(fromb) - 1] = '\0';
+ (void) strlcpy(fromb, hp->h_name, sizeof(fromb));
from = fromb;
/* Check for spoof, ala rlogind */
diff --git a/usr.sbin/lpr/lpd/printjob.c b/usr.sbin/lpr/lpd/printjob.c
index b2fd1fef27d..6b1b63d4d15 100644
--- a/usr.sbin/lpr/lpd/printjob.c
+++ b/usr.sbin/lpr/lpd/printjob.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: printjob.c,v 1.21 2001/02/15 05:20:35 deraadt Exp $ */
+/* $OpenBSD: printjob.c,v 1.22 2001/06/22 15:27:20 lebel Exp $ */
/* $NetBSD: printjob.c,v 1.9.4.3 1996/07/12 22:31:39 jtc Exp $ */
/*
@@ -376,17 +376,14 @@ printit(file)
while (getline(cfp))
switch (line[0]) {
case 'H':
- strncpy(fromhost, line+1, sizeof(fromhost)-1);
- fromhost[sizeof(fromhost)-1] = '\0';
+ strlcpy(fromhost, line+1, sizeof(fromhost));
if (class[0] == '\0') {
- strncpy(class, line+1, sizeof(class)-1);
- class[sizeof(class)-1] = '\0';
+ strlcpy(class, line+1, sizeof(class));
}
continue;
case 'P':
- strncpy(logname, line+1, sizeof(logname)-1);
- logname[sizeof(logname)-1] = '\0';
+ strlcpy(logname, line+1, sizeof(logname));
if (RS) { /* restricted */
if (getpwnam(logname) == NULL) {
bombed = NOACCT;
@@ -411,23 +408,20 @@ printit(file)
case 'J':
if (line[1] != '\0') {
- strncpy(jobname, line+1, sizeof(jobname)-1);
- jobname[sizeof(jobname)-1] = '\0';
+ strlcpy(jobname, line+1, sizeof(jobname));
} else
strcpy(jobname, " ");
continue;
case 'C':
if (line[1] != '\0')
- strncpy(class, line+1, sizeof(class)-1);
+ strlcpy(class, line+1, sizeof(class));
else if (class[0] == '\0')
gethostname(class, sizeof(class));
- class[sizeof(class)-1] = '\0';
continue;
case 'T': /* header title for pr */
- strncpy(title, line+1, sizeof(title)-1);
- title[sizeof(title)-1] = '\0';
+ strlcpy(title, line+1, sizeof(title));
continue;
case 'L': /* identification line */
@@ -440,20 +434,17 @@ printit(file)
case '3':
case '4':
if (line[1] != '\0') {
- strncpy(fonts[line[0]-'1'], line+1,
- 50-1);
- fonts[line[0]-'1'][50-1] = '\0';
+ strlcpy(fonts[line[0]-'1'], line+1,
+ 50);
}
continue;
case 'W': /* page width */
- strncpy(width+2, line+1, sizeof(width)-3);
- width[2+sizeof(width)-3] = '\0';
+ strlcpy(width+2, line+1, sizeof(width)-2);
continue;
case 'I': /* indent amount */
- strncpy(indent+2, line+1, sizeof(indent)-3);
- indent[2+sizeof(indent)-3] = '\0';
+ strlcpy(indent+2, line+1, sizeof(indent)-2);
continue;
default: /* some file to print */
diff --git a/usr.sbin/lpr/lpd/recvjob.c b/usr.sbin/lpr/lpd/recvjob.c
index 9ae673c4f53..11739e3029d 100644
--- a/usr.sbin/lpr/lpd/recvjob.c
+++ b/usr.sbin/lpr/lpd/recvjob.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: recvjob.c,v 1.13 2001/02/07 20:40:46 todd Exp $ */
+/* $OpenBSD: recvjob.c,v 1.14 2001/06/22 15:27:20 lebel Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)recvjob.c 8.2 (Berkeley) 4/27/95";
#else
-static char rcsid[] = "$OpenBSD: recvjob.c,v 1.13 2001/02/07 20:40:46 todd Exp $";
+static char rcsid[] = "$OpenBSD: recvjob.c,v 1.14 2001/06/22 15:27:20 lebel Exp $";
#endif
#endif /* not lint */
@@ -178,10 +178,8 @@ readjob()
* something different than what gethostbyaddr()
* returns
*/
- strncpy(cp + 6, from, sizeof(line) + line - cp - 7);
- line[sizeof(line) -1 ] = '\0';
- strncpy(tfname, cp, sizeof tfname-1);
- tfname[sizeof tfname-1] = '\0';
+ strlcpy(cp + 6, from, sizeof(line) + line - cp - 6);
+ strlcpy(tfname, cp, sizeof tfname);
tfname[0] = 't';
if (strchr(tfname, '/'))
frecverr("readjob: %s: illegal path name",
@@ -211,8 +209,7 @@ readjob()
(void) write(1, "\2", 1);
continue;
}
- (void) strncpy(dfname, cp, sizeof dfname-1);
- dfname[sizeof dfname-1] = '\0';
+ (void) strlcpy(dfname, cp, sizeof dfname);
if (strchr(dfname, '/'))
frecverr("readjob: %s: illegal path name",
dfname);