diff --git a/src/util-strings.c b/src/util-strings.c index e0a2c6b..d55f774 100644 --- a/src/util-strings.c +++ b/src/util-strings.c @@ -184,9 +184,6 @@ strreplace(const char *string, const char *separator, const char *replacement) char *r = calloc(max + 1, 1); /* the result, one extra for terminating \0 */ char *destptr = r; -/* our strncpy calls truncate the second argument, we know... */ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstringop-truncation" while (next) { size_t len = next - current; /* silently truncate because we really don't care about this @@ -195,11 +192,11 @@ strreplace(const char *string, const char *separator, const char *replacement) break; /* Copy the source string over, then append the separator */ - strncpy(destptr, current, len); + memcpy(destptr, current, len); destptr += len; if (destptr + rlen > r + max) break; - strncpy(destptr, replacement, rlen); + memcpy(destptr, replacement, rlen); destptr += rlen; current = next + splen; @@ -213,10 +210,9 @@ strreplace(const char *string, const char *separator, const char *replacement) /* silently truncate because we really don't care about this * case */ if (destptr + len <= r + max) { - strncpy(destptr, current, len); + memcpy(destptr, current, len); destptr += len; } -#pragma GCC diagnostic pop void *tmp = realloc(r, (destptr - r) + 1); assert(tmp);