diff options
author | Pablo M. Bermudo Garay <pablombg@gmail.com> | 2016-08-22 12:56:14 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2016-08-23 14:03:21 +0200 |
commit | b2b811ed4a8261430def40b7d600ccb0f4927492 (patch) | |
tree | 5cc5a3e65caafee3c36696d71c632785628ddec8 /extensions | |
parent | 2abd049177fa42993e4b1de588e92282a200ee43 (diff) |
xtables-translate: add escape_quotes option to comment_xlate
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>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/libxt_comment.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/extensions/libxt_comment.c b/extensions/libxt_comment.c index 0e31eddf..b635d16c 100644 --- a/extensions/libxt_comment.c +++ b/extensions/libxt_comment.c @@ -52,9 +52,18 @@ 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, "\\\"%s\\\"", + commentinfo->comment); + else + snprintf(comment, XT_MAX_COMMENT_LEN, "\"%s\"", + commentinfo->comment); + + comment[XT_MAX_COMMENT_LEN - 1] = '\0'; + xt_xlate_add_comment(xl, comment); return 1; } |