From 28711d308d9d70801ac0c9552df834ddafff2385 Mon Sep 17 00:00:00 2001 From: Tom Marshall Date: Wed, 10 Feb 2016 00:01:41 -0500 Subject: toybox: tar: Fix support for long names Pathnames may be longer than the name field in the header, so use strncpy() instead of xstrncpy() to avoid bailing out. Also add unit tests to ensure proper handling of short and long pathnames. Change-Id: Id025891993746889564b479e5185cf9721b54a55 --- toys/pending/tar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'toys/pending') diff --git a/toys/pending/tar.c b/toys/pending/tar.c index 6140ea5d..4f4de0b5 100644 --- a/toys/pending/tar.c +++ b/toys/pending/tar.c @@ -190,7 +190,7 @@ static void add_file(struct archive_handler *tar, char **nam, struct stat *st) } memset(&hdr, 0, sizeof(hdr)); - xstrncpy(hdr.name, hname, sizeof(hdr.name)); + strncpy(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); -- cgit v1.2.3