summaryrefslogtreecommitdiff
path: root/src/database.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2019-02-13 15:44:03 +0200
committerTimo Teräs <timo.teras@iki.fi>2019-02-13 16:05:27 +0200
commit44daf808737f85ff462905269c7a1e66d52e2fff (patch)
tree08a62633282647b9695adc2a460b1dbe0799bab6 /src/database.c
parent86922d1a34fc1004f439b0b86bfbd908a9f07422 (diff)
downloadapk-tools-44daf808737f85ff462905269c7a1e66d52e2fff.tar.gz
apk-tools-44daf808737f85ff462905269c7a1e66d52e2fff.tar.bz2
apk-tools-44daf808737f85ff462905269c7a1e66d52e2fff.tar.xz
apk-tools-44daf808737f85ff462905269c7a1e66d52e2fff.zip
fix strncpy bounds errors
error: 'strncpy' specified bound 4096 equals destination size [-Werror=stringop-truncation] Based on patch by Elan Ruusamäe <glen@delfi.ee>
Diffstat (limited to 'src/database.c')
-rw-r--r--src/database.c5
1 files changed, 4 insertions, 1 deletions
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))