diff options
author | lebel <lebel@cvs.openbsd.org> | 2001-06-26 14:19:34 +0000 |
---|---|---|
committer | lebel <lebel@cvs.openbsd.org> | 2001-06-26 14:19:34 +0000 |
commit | e18c93f19f53552be2829b87f64f87ee79206eb5 (patch) | |
tree | 02ce13510c378662a0f07447fd6cff4828a7c299 /bin/pax/tar.c | |
parent | a4a9d4521851ba0ec4f6626337a29280dd569417 (diff) |
use strlcpy vs strncpy+a[len-1]='\0'
Diffstat (limited to 'bin/pax/tar.c')
-rw-r--r-- | bin/pax/tar.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/bin/pax/tar.c b/bin/pax/tar.c index a576ffd22c2..e088dd36375 100644 --- a/bin/pax/tar.c +++ b/bin/pax/tar.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tar.c,v 1.18 2001/05/26 00:32:21 millert Exp $ */ +/* $OpenBSD: tar.c,v 1.19 2001/06/26 14:19:33 lebel Exp $ */ /* $NetBSD: tar.c,v 1.5 1995/03/21 09:07:49 cgd Exp $ */ /*- @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)tar.c 8.2 (Berkeley) 4/18/94"; #else -static char rcsid[] = "$OpenBSD: tar.c,v 1.18 2001/05/26 00:32:21 millert Exp $"; +static char rcsid[] = "$OpenBSD: tar.c,v 1.19 2001/06/26 14:19:33 lebel Exp $"; #endif #endif /* not lint */ @@ -1020,8 +1020,7 @@ ustar_wr(arcn) * occur, we remove the / and copy the first part to the prefix */ *pt = '\0'; - strncpy(hd->prefix, arcn->name, sizeof(hd->prefix) - 1); - hd->prefix[sizeof(hd->prefix) - 1] = '\0'; + strncpy(hd->prefix, arcn->name, sizeof(hd->prefix)); *pt++ = '/'; } else memset(hd->prefix, 0, sizeof(hd->prefix)); @@ -1030,8 +1029,7 @@ ustar_wr(arcn) * copy the name part. this may be the whole path or the part after * the prefix */ - strncpy(hd->name, pt, sizeof(hd->name) - 1); - hd->name[sizeof(hd->name) - 1] = '\0'; + strncpy(hd->name, pt, sizeof(hd->name)); /* * set the fields in the header that are type dependent @@ -1074,8 +1072,7 @@ ustar_wr(arcn) hd->typeflag = SYMTYPE; else hd->typeflag = LNKTYPE; - strncpy(hd->linkname,arcn->ln_name, sizeof(hd->linkname) - 1); - hd->linkname[sizeof(hd->linkname) - 1] = '\0'; + strncpy(hd->linkname,arcn->ln_name, sizeof(hd->linkname)); memset(hd->devmajor, 0, sizeof(hd->devmajor)); memset(hd->devminor, 0, sizeof(hd->devminor)); if (ul_oct((u_long)0L, hd->size, sizeof(hd->size), 3)) |