Skip to contentSkip to conversation

expr: missing offset handling for snprintf() in hash and numgen

PATCH New Pablo Neira Ayuso 1 participant 1 message Oct 31, 2016 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 expr: missing offset handling for snprintf() in hash and numgen

Fix incorrect output when offset attribute is unset.

---
 src/expr/hash.c   | 2 +-
 src/expr/numgen.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
src/expr/hash.c +1 -1
index c235502870e6..83f93179c26d 100644
@@ -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);
 	}
 
src/expr/numgen.c +1 -1
index e4e055e347a3..a15f03ae834b 100644
@@ -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);
 	}
 
Signature · 1 line
2.1.4