From 1e08944f4656d7bd3b8da07536111cc3aac330eb Mon Sep 17 00:00:00 2001 From: gad Date: Sun, 22 Jul 2001 07:25:27 +0000 Subject: 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 --- usr.sbin/lpr/common_source/displayq.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'usr.sbin/lpr/common_source') 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); } -- cgit v1.1