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/database.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/database.c') diff --git a/src/database.c b/src/database.c index 8e58785..5bffb43 100644 --- a/src/database.c +++ b/src/database.c @@ -2787,7 +2787,10 @@ static int apk_db_unpack_pkg(struct apk_database *db, if (!(pkg->repos & db->local_repos)) need_copy = TRUE; } else { - strncpy(file, pkg->filename, sizeof(file)); + if (strlcpy(file, pkg->filename, sizeof file) >= sizeof file) { + r = -ENAMETOOLONG; + goto err_msg; + } need_copy = TRUE; } if (!apk_db_cache_active(db)) -- cgit v1.2.3-60-g2f50