Skip to contentSkip to conversation

data_reg: fix bad buffer size bounds

PATCH Applied Arturo Borrero Gonzalez 2 participants 2 messages May 6, 2014 – May 7, 2014 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 data_reg: fix bad buffer size bounds

These calls need to use the new buffer size, instead of the size that the buffer originally had.

Bugs introduced by myself at dec68741 [data_reg: fix verdict format approach].

---
 src/expr/data_reg.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
src/expr/data_reg.c +5 -5
index 0523cb7..44281f7 100644
@@ -304,7 +304,7 @@ nft_data_reg_verdict_snprintf_def(char *buf, size_t size,
 	SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 
 	if (reg->chain != NULL) {
-		ret = snprintf(buf+offset, size, "-> %s ", reg->chain);
+		ret = snprintf(buf+offset, len, "-> %s ", reg->chain);
 		SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 	}
 
@@ -322,12 +322,12 @@ nft_data_reg_verdict_snprintf_xml(char *buf, size_t size,
 	SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 
 	if (reg->chain != NULL) {
-		ret = snprintf(buf+offset, size, "<chain>%s</chain>",
+		ret = snprintf(buf+offset, len, "<chain>%s</chain>",
 			       reg->chain);
 		SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 	}
 
-	ret = snprintf(buf+offset, size, "</data_reg>");
+	ret = snprintf(buf+offset, len, "</data_reg>");
 	SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 
 	return offset;
@@ -344,12 +344,12 @@ nft_data_reg_verdict_snprintf_json(char *buf, size_t size,
 	SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 
 	if (reg->chain != NULL) {
-		ret = snprintf(buf+offset, size, ",\"chain\":\"%s\"",
+		ret = snprintf(buf+offset, len, ",\"chain\":\"%s\"",
 			       reg->chain);
 		SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 	}
 
-	ret = snprintf(buf+offset, size, "}");
+	ret = snprintf(buf+offset, len, "}");
 	SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 
 	return offset;
maintainer Applied
#1 lore raw
Quoted 4 lines · Arturo Borrero Gonzalez

These calls need to use the new buffer size, instead of the size that the buffer originally had.

Bugs introduced by myself at dec68741 [data_reg: fix verdict format approach].

Applied, thanks Arturo.