From 44daf808737f85ff462905269c7a1e66d52e2fff Mon Sep 17 00:00:00 2001 From: Timo Teräs Date: Wed, 13 Feb 2019 15:44:03 +0200 Subject: fix strncpy bounds errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit error: 'strncpy' specified bound 4096 equals destination size [-Werror=stringop-truncation] Based on patch by Elan Ruusamäe --- src/archive.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/archive.c') diff --git a/src/archive.c b/src/archive.c index 1745056..724410c 100644 --- a/src/archive.c +++ b/src/archive.c @@ -387,10 +387,10 @@ int apk_tar_write_entry(struct apk_ostream *os, const struct apk_file_info *ae, return -1; if (ae->name != NULL) - strncpy(buf.name, ae->name, sizeof(buf.name)); + strlcpy(buf.name, ae->name, sizeof buf.name); - strncpy(buf.uname, ae->uname ?: "root", sizeof(buf.uname)); - strncpy(buf.gname, ae->gname ?: "root", sizeof(buf.gname)); + strlcpy(buf.uname, ae->uname ?: "root", sizeof buf.uname); + strlcpy(buf.gname, ae->gname ?: "root", sizeof buf.gname); PUT_OCTAL(buf.size, ae->size); PUT_OCTAL(buf.uid, ae->uid); -- cgit v1.2.3-60-g2f50