From: Pablo Neira Ayuso Date: Mon, 31 Oct 2016 12:30:31 +0000 (+0100) Subject: expr: missing offset handling for snprintf() in hash and numgen X-Git-Tag: libnftnl-1.0.7~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5541b7d725ac1f25548a7fa05f6c89b69384120b;p=thirdparty%2Flibnftnl.git expr: missing offset handling for snprintf() in hash and numgen Fix incorrect output when offset attribute is unset. Signed-off-by: Pablo Neira Ayuso --- diff --git a/src/expr/hash.c b/src/expr/hash.c index c2355028..83f93179 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 e4e055e3..a15f03ae 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); }