From b50bfa2a162f74fdbe54689cf356b258ce2b8009 Mon Sep 17 00:00:00 2001 From: Akash Rawal Date: Fri, 24 Nov 2017 13:03:03 +0530 Subject: [PATCH] Fix build failure po/POTFILES.in: Update unit-tests/test-dl-dummy.c: Remove strncpy --- po/POTFILES.in | 1 + unit-tests/test-dl-dummy.c | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index 5943b40cd..142d01509 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,5 +1,6 @@ lib/error.c lib/gai_strerror.c +lib/regcomp.c lib/spawn-pipe.c lib/w32spawn.h lib/wait-process.c diff --git a/unit-tests/test-dl-dummy.c b/unit-tests/test-dl-dummy.c index c5ce16963..996824c76 100644 --- a/unit-tests/test-dl-dummy.c +++ b/unit-tests/test-dl-dummy.c @@ -32,6 +32,14 @@ #define concat2(x, y) x ## y #define concat(x, y) concat2(x, y) +static void strcpy_safe(char *dest, const char *src, size_t len) +{ + size_t i; + for (i = 0; i < (len - 1) && src[i]; i++) + dest[i] = src[i]; + dest[i] = 0; +} + WGET_EXPORT void dl_test_write_param(char *buf, size_t len); WGET_EXPORT void concat(dl_test_fn_, PARAM)(char *buf, size_t len); @@ -40,13 +48,11 @@ void dl_test_write_param(char *buf, size_t len) //TODO: Check out clang static analyser issue fixed by @rootkea // Problem with replacing strcpy with wget_strlcpy is, that libwget is not available here. //wget_strlcpy(buf, stringify(PARAM), len); - strncpy(buf, stringify(PARAM), len - 1); - buf[len - 1] = 0; + strcpy_safe(buf, stringify(PARAM), len - 1); } void concat(dl_test_fn_, PARAM)(char *buf, size_t len) { //wget_strlcpy(buf, stringify(PARAM), len); - strncpy(buf, stringify(PARAM), len - 1); - buf[len - 1] = 0; + strcpy_safe(buf, stringify(PARAM), len - 1); }