From b485c92efac16d94a6a613bb6f839f36ba0b28be Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Thu, 25 Jul 2019 23:50:46 +0200 Subject: Use safer string copy function to fill tar header Signed-off-by: David Oberhollenzer --- lib/tar/write_header.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/tar') diff --git a/lib/tar/write_header.c b/lib/tar/write_header.c index 19b00bd..0686200 100644 --- a/lib/tar/write_header.c +++ b/lib/tar/write_header.c @@ -65,7 +65,7 @@ static int write_header(int fd, const struct stat *sb, const char *name, memset(&hdr, 0, sizeof(hdr)); - memcpy(hdr.name, name, strlen(name)); + strncpy(hdr.name, name, sizeof(hdr.name) - 1); write_number(hdr.mode, sb->st_mode & ~S_IFMT, sizeof(hdr.mode)); write_number(hdr.uid, sb->st_uid, sizeof(hdr.uid)); write_number(hdr.gid, sb->st_gid, sizeof(hdr.gid)); -- cgit v1.2.3