aboutsummaryrefslogtreecommitdiffstats
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)
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))