From 82effc97f9f2d1c258ea50cb11b130753b8ba805 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 1 Jan 2015 16:59:35 -0600 Subject: Switch a lot of strncpy() calls to xstrncpy(). --- toys/pending/tar.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'toys/pending/tar.c') diff --git a/toys/pending/tar.c b/toys/pending/tar.c index 5b060c6e..dc1480c4 100644 --- a/toys/pending/tar.c +++ b/toys/pending/tar.c @@ -189,7 +189,7 @@ static void add_file(struct archive_handler *tar, char **nam, struct stat *st) } memset(&hdr, 0, sizeof(hdr)); - strncpy(hdr.name, hname, sizeof(hdr.name)); + xstrncpy(hdr.name, hname, sizeof(hdr.name)); itoo(hdr.mode, sizeof(hdr.mode), st->st_mode &07777); itoo(hdr.uid, sizeof(hdr.uid), st->st_uid); itoo(hdr.gid, sizeof(hdr.gid), st->st_gid); @@ -202,7 +202,7 @@ static void add_file(struct archive_handler *tar, char **nam, struct stat *st) hdr.type = '1'; if (strlen(node->arg) > sizeof(hdr.link)) write_longname(tar, hname, 'K'); //write longname LINK - strncpy(hdr.link, node->arg, sizeof(hdr.link)); + xstrncpy(hdr.link, node->arg, sizeof(hdr.link)); } else if (S_ISREG(st->st_mode)) { hdr.type = '0'; if (st->st_size <= (off_t)0777777777777LL) @@ -219,7 +219,7 @@ static void add_file(struct archive_handler *tar, char **nam, struct stat *st) } if (strlen(lnk) > sizeof(hdr.link)) write_longname(tar, hname, 'K'); //write longname LINK - strncpy(hdr.link, lnk, sizeof(hdr.link)); + xstrncpy(hdr.link, lnk, sizeof(hdr.link)); free(lnk); } else if (S_ISDIR(st->st_mode)) hdr.type = '5'; -- cgit v1.2.3