]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
extensions: libxt_string: Avoid buffer size warning for strncpy()
authorPhil Sutter <phil@nwl.cc>
Wed, 2 Jun 2021 13:15:37 +0000 (15:15 +0200)
committerPhil Sutter <phil@nwl.cc>
Mon, 7 Jun 2021 12:50:27 +0000 (14:50 +0200)
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 <phil@nwl.cc>
extensions/libxt_string.c

index 7c6366cbbf1b39b27d11472814865660836b6c8b..739a8e7fd66b6846ddf5bad06eebd2b821a54f96 100644 (file)
@@ -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;
        }