Skip to content

Commit

Permalink
Fix build failure
Browse files Browse the repository at this point in the history
po/POTFILES.in: Update
unit-tests/test-dl-dummy.c: Remove strncpy
  • Loading branch information
akashrawal committed Nov 24, 2017
1 parent d7b28c6 commit b50bfa2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions 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
Expand Down
14 changes: 10 additions & 4 deletions unit-tests/test-dl-dummy.c
Expand Up @@ -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);

Expand All @@ -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);
}

0 comments on commit b50bfa2

Please sign in to comment.