summaryrefslogtreecommitdiffstats
path: root/usr.sbin/lpr/common_source
diff options
context:
space:
mode:
authorgad <gad@FreeBSD.org>2001-07-22 07:25:27 +0000
committergad <gad@FreeBSD.org>2001-07-22 07:25:27 +0000
commit1e08944f4656d7bd3b8da07536111cc3aac330eb (patch)
treef9e0ff51825cce4ee1035c59b1b60338ca388b60 /usr.sbin/lpr/common_source
parentcaf592b72e15f59512403d219d57a444b4c4874e (diff)
downloadFreeBSD-src-1e08944f4656d7bd3b8da07536111cc3aac330eb.zip
FreeBSD-src-1e08944f4656d7bd3b8da07536111cc3aac330eb.tar.gz
Replace calls to strncpy with calls to strlcpy, and remove the extra step
needed to ensure that the result is null-terminated when using strncpy(). MFC after: 8 days
Diffstat (limited to 'usr.sbin/lpr/common_source')
-rw-r--r--usr.sbin/lpr/common_source/displayq.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/usr.sbin/lpr/common_source/displayq.c b/usr.sbin/lpr/common_source/displayq.c
index c4233c5..7727306 100644
--- a/usr.sbin/lpr/common_source/displayq.c
+++ b/usr.sbin/lpr/common_source/displayq.c
@@ -337,8 +337,7 @@ inform(const struct printer *pp, char *cf)
if (line[0] < 'a' || line[0] > 'z')
break;
if (copycnt == 0 || strcmp(file, line+1) != 0) {
- strncpy(file, line + 1, sizeof(file) - 1);
- file[sizeof(file) - 1] = '\0';
+ strlcpy(file, line + 1, sizeof(file));
}
copycnt++;
/*
@@ -348,8 +347,7 @@ inform(const struct printer *pp, char *cf)
*/
continue;
case 'N':
- strncpy(savedname, line + 1, sizeof(savedname) - 1);
- savedname[sizeof(savedname) - 1] = '\0';
+ strlcpy(savedname, line + 1, sizeof(savedname));
break;
}
if ((file[0] != '\0') && (savedname[0] != '\0')) {
@@ -364,8 +362,7 @@ inform(const struct printer *pp, char *cf)
if (file[0] != '\0') {
if (savedname[0] == '\0') {
/* a safeguard in case the N-ame line is missing */
- strncpy(savedname, file, sizeof(savedname) - 1);
- savedname[sizeof(savedname) - 1] = '\0';
+ strlcpy(savedname, file, sizeof(savedname));
}
show(savedname, file, copycnt);
}
OpenPOWER on IntegriCloud