[PATCH libnftnl] expr: missing offset handling for snprintf() in hash and numgen

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fix incorrect output when offset attribute is unset.

Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
---
 src/expr/hash.c   | 2 +-
 src/expr/numgen.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/expr/hash.c b/src/expr/hash.c
index c235502870e6..83f93179c26d 100644
--- a/src/expr/hash.c
+++ b/src/expr/hash.c
@@ -220,7 +220,7 @@ nftnl_expr_hash_snprintf_default(char *buf, size_t size,
 	SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 
 	if (hash->offset) {
-		ret = snprintf(buf, len, "offset %u ", hash->offset);
+		ret = snprintf(buf + offset, len, "offset %u ", hash->offset);
 		SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 	}
 
diff --git a/src/expr/numgen.c b/src/expr/numgen.c
index e4e055e347a3..a15f03ae834b 100644
--- a/src/expr/numgen.c
+++ b/src/expr/numgen.c
@@ -194,7 +194,7 @@ nftnl_expr_ng_snprintf_default(char *buf, size_t size,
 	}
 
 	if (ng->offset) {
-		ret = snprintf(buf, len, "offset %u ", ng->offset);
+		ret = snprintf(buf + offset, len, "offset %u ", ng->offset);
 		SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 	}
 
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux