From: "Pablo M. Bermudo Garay" <pablombg@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: "Pablo M. Bermudo Garay" <pablombg@gmail.com>
Subject: [PATCH iptables 1/2] xtables-translate: add escape_quotes option to comment_xlate
Date: Tue, 16 Aug 2016 19:44:32 +0200 [thread overview]
Message-ID: <20160816174433.28272-1-pablombg@gmail.com> (raw)
The comment_xlate function was not supporting this option that is
necessary in some situations.
Signed-off-by: Pablo M. Bermudo Garay <pablombg@gmail.com>
---
| 9 ++++++++-
iptables/nft-ipv4.c | 2 +-
iptables/nft-ipv6.c | 2 +-
3 files changed, 10 insertions(+), 3 deletions(-)
--git a/extensions/libxt_comment.c b/extensions/libxt_comment.c
index 0e31edd..bf9a039 100644
--- a/extensions/libxt_comment.c
+++ b/extensions/libxt_comment.c
@@ -52,9 +52,16 @@ static int comment_xlate(struct xt_xlate *xl,
const struct xt_xlate_mt_params *params)
{
struct xt_comment_info *commentinfo = (void *)params->match->data;
+ char comment[XT_MAX_COMMENT_LEN];
commentinfo->comment[XT_MAX_COMMENT_LEN - 1] = '\0';
- xt_xlate_add_comment(xl, commentinfo->comment);
+ if (params->escape_quotes)
+ snprintf(comment, XT_MAX_COMMENT_LEN, "comment \\\"%s\\\"",
+ commentinfo->comment);
+ else
+ snprintf(comment, XT_MAX_COMMENT_LEN, "comment \"%s\"",
+ commentinfo->comment);
+ xt_xlate_add_comment(xl, comment);
return 1;
}
diff --git a/iptables/nft-ipv4.c b/iptables/nft-ipv4.c
index 50706cb..f5c0d95 100644
--- a/iptables/nft-ipv4.c
+++ b/iptables/nft-ipv4.c
@@ -490,7 +490,7 @@ static int nft_ipv4_xlate(const void *data, struct xt_xlate *xl)
comment = xt_xlate_get_comment(xl);
if (comment)
- xt_xlate_add(xl, "comment \\\"%s\\\" ", comment);
+ xt_xlate_add(xl, "%s", comment);
ret = xlate_action(cs, !!(cs->fw.ip.flags & IPT_F_GOTO), xl);
diff --git a/iptables/nft-ipv6.c b/iptables/nft-ipv6.c
index 8ca523c..3792c68 100644
--- a/iptables/nft-ipv6.c
+++ b/iptables/nft-ipv6.c
@@ -439,7 +439,7 @@ static int nft_ipv6_xlate(const void *data, struct xt_xlate *xl)
comment = xt_xlate_get_comment(xl);
if (comment)
- xt_xlate_add(xl, "comment \\\"%s\\\" ", comment);
+ xt_xlate_add(xl, "%s", comment);
ret = xlate_action(cs, !!(cs->fw6.ipv6.flags & IP6T_F_GOTO), xl);
--
2.9.3
next reply other threads:[~2016-08-16 17:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-16 17:44 Pablo M. Bermudo Garay [this message]
2016-08-16 17:44 ` [PATCH iptables 2/2] xtables-translate-restore: do not escape quotes Pablo M. Bermudo Garay
2016-08-17 14:28 ` Pablo Neira Ayuso
2016-08-17 14:23 ` [PATCH iptables 1/2] xtables-translate: add escape_quotes option to comment_xlate Pablo Neira Ayuso
2016-08-18 15:59 ` Pablo M. Bermudo Garay
2016-08-18 16:10 ` 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=20160816174433.28272-1-pablombg@gmail.com \
--to=pablombg@gmail.com \
--cc=netfilter-devel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.