Blame SOURCES/0013-extensions-libxt_string-Avoid-buffer-size-warning-fo.patch
|
|
3a00e5 |
From 2b659cc251cd4a6d15e2c5962bb763c8dea48e1a Mon Sep 17 00:00:00 2001
|
|
|
3a00e5 |
From: Phil Sutter <phil@nwl.cc>
|
|
|
3a00e5 |
Date: Wed, 2 Jun 2021 15:15:37 +0200
|
|
|
3a00e5 |
Subject: [PATCH] extensions: libxt_string: Avoid buffer size warning for
|
|
|
3a00e5 |
strncpy()
|
|
|
3a00e5 |
|
|
|
3a00e5 |
If the target buffer does not need to be null-terminated, one may simply
|
|
|
3a00e5 |
use memcpy() and thereby avoid any compiler warnings.
|
|
|
3a00e5 |
|
|
|
3a00e5 |
Signed-off-by: Phil Sutter <phil@nwl.cc>
|
|
|
3a00e5 |
(cherry picked from commit 68ed965b35cdc7b55d4ebc0ba37c1ac078ccbafb)
|
|
|
3a00e5 |
---
|
|
|
3a00e5 |
extensions/libxt_string.c | 2 +-
|
|
|
3a00e5 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
3a00e5 |
|
|
|
3a00e5 |
diff --git a/extensions/libxt_string.c b/extensions/libxt_string.c
|
|
|
3a00e5 |
index 7c6366cbbf1b3..739a8e7fd66b6 100644
|
|
|
3a00e5 |
--- a/extensions/libxt_string.c
|
|
|
3a00e5 |
+++ b/extensions/libxt_string.c
|
|
|
3a00e5 |
@@ -81,7 +81,7 @@ parse_string(const char *s, struct xt_string_info *info)
|
|
|
3a00e5 |
{
|
|
|
3a00e5 |
/* xt_string does not need \0 at the end of the pattern */
|
|
|
3a00e5 |
if (strlen(s) <= XT_STRING_MAX_PATTERN_SIZE) {
|
|
|
3a00e5 |
- strncpy(info->pattern, s, XT_STRING_MAX_PATTERN_SIZE);
|
|
|
3a00e5 |
+ memcpy(info->pattern, s, XT_STRING_MAX_PATTERN_SIZE);
|
|
|
3a00e5 |
info->patlen = strnlen(s, XT_STRING_MAX_PATTERN_SIZE);
|
|
|
3a00e5 |
return;
|
|
|
3a00e5 |
}
|
|
|
3a00e5 |
--
|
|
|
3a00e5 |
2.31.1
|
|
|
3a00e5 |
|