From 5541b7d725ac1f25548a7fa05f6c89b69384120b Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Mon, 31 Oct 2016 13:30:31 +0100 Subject: expr: missing offset handling for snprintf() in hash and numgen Fix incorrect output when offset attribute is unset. Signed-off-by: Pablo Neira Ayuso --- src/expr/hash.c | 2 +- src/expr/numgen.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/expr/hash.c b/src/expr/hash.c index c235502..83f9317 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 e4e055e..a15f03a 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); } -- cgit v1.2.3