From: Phil Sutter Date: Wed, 2 Jun 2021 13:15:37 +0000 (+0200) Subject: extensions: libxt_string: Avoid buffer size warning for strncpy() X-Git-Tag: v1.8.8~152 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=68ed965b35cdc7b55d4ebc0ba37c1ac078ccbafb;p=thirdparty%2Fiptables.git extensions: libxt_string: Avoid buffer size warning for strncpy() If the target buffer does not need to be null-terminated, one may simply use memcpy() and thereby avoid any compiler warnings. Signed-off-by: Phil Sutter --- diff --git a/extensions/libxt_string.c b/extensions/libxt_string.c index 7c6366cb..739a8e7f 100644 --- a/extensions/libxt_string.c +++ b/extensions/libxt_string.c @@ -81,7 +81,7 @@ parse_string(const char *s, struct xt_string_info *info) { /* xt_string does not need \0 at the end of the pattern */ if (strlen(s) <= XT_STRING_MAX_PATTERN_SIZE) { - strncpy(info->pattern, s, XT_STRING_MAX_PATTERN_SIZE); + memcpy(info->pattern, s, XT_STRING_MAX_PATTERN_SIZE); info->patlen = strnlen(s, XT_STRING_MAX_PATTERN_SIZE); return; }