diff --git a/src/bind_config.c b/src/bind_config.c index 3959cc22c..929e4cca0 100644 --- a/src/bind_config.c +++ b/src/bind_config.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -45,7 +46,7 @@ int config_parse(const char *json) if (xp >= ep) break; } xp = (ep > json + 10) ? ep - 10 : json; - strncpy(buffer, xp, sizeof(buffer)); + strlcpy(buffer, xp, sizeof(buffer)); buffer[9] = 0; log_error("json parse error in line %d, position %d, near `%s`\n", line, ep - lp, buffer); } diff --git a/src/helpers.c b/src/helpers.c index aa9bc12eb..e9502e075 100644 --- a/src/helpers.c +++ b/src/helpers.c @@ -167,7 +167,7 @@ static int lua_callspell(castorder * co) if (hashpos != NULL) { ptrdiff_t len = hashpos - fname; assert(len < (ptrdiff_t) sizeof(fbuf)); - strncpy(fbuf, fname, len); + memcpy(fbuf, fname, len); fbuf[len] = '\0'; fname = fbuf; } diff --git a/src/util/log.test.c b/src/util/log.test.c index 95cbefa96..55616c026 100644 --- a/src/util/log.test.c +++ b/src/util/log.test.c @@ -12,7 +12,7 @@ void log_string(void *data, int level, const char *module, const char *format, v unused_arg(format); unused_arg(module); unused_arg(level); - strncpy(str, arg, 32); + strcpy(str, arg); } static void test_logging(CuTest * tc)