diff options
author | Timo Teräs <timo.teras@iki.fi> | 2019-02-13 15:44:03 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2019-02-13 16:05:27 +0200 |
commit | 44daf808737f85ff462905269c7a1e66d52e2fff (patch) | |
tree | 08a62633282647b9695adc2a460b1dbe0799bab6 /src/blob.c | |
parent | 86922d1a34fc1004f439b0b86bfbd908a9f07422 (diff) | |
download | apk-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/blob.c')
-rw-r--r-- | src/blob.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -717,3 +717,16 @@ apk_blob_t *apk_blob_atomize_dup(apk_blob_t blob) return &atom->blob; } + +#if defined(__GLIBC__) && !defined(__UCLIBC__) +size_t strlcpy(char *dst, const char *src, size_t size) +{ + size_t ret = strlen(src), len; + if (!size) return ret; + len = ret; + if (len >= size) len = size - 1; + memcpy(dest, src, len); + dst[len] = 0; + return ret; +} +#endif |