From: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: pablo@netfilter.org
Subject: [libnftnl PATCH] data_reg: fix bad buffer size bounds
Date: Tue, 06 May 2014 19:19:46 +0200 [thread overview]
Message-ID: <20140506171946.4163.82349.stgit@nfdev.cica.es> (raw)
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].
Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
---
src/expr/data_reg.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/expr/data_reg.c b/src/expr/data_reg.c
index 0523cb7..44281f7 100644
--- a/src/expr/data_reg.c
+++ b/src/expr/data_reg.c
@@ -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;
next reply other threads:[~2014-05-06 17:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-06 17:19 Arturo Borrero Gonzalez [this message]
2014-05-07 13:39 ` [libnftnl PATCH] data_reg: fix bad buffer size bounds Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140506171946.4163.82349.stgit@nfdev.cica.es \
--to=arturo.borrero.glez@gmail.com \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).