All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philip Craig <philipc@snapgear.com>
To: netfilter-devel <netfilter-devel@lists.netfilter.org>
Subject: [PATCH] fix iptables-restore escaping of quotes
Date: Mon, 20 Dec 2004 16:31:57 +1000	[thread overview]
Message-ID: <41C671DD.2070207@snapgear.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 379 bytes --]

iptables-restore was losing a character at the start of the parameter
for every escaped quote within the parameter.

This is of signifance when there are " characters in log prefixes.
Note that iptables-save can't generate escaped quotes;  I am
generating the input for iptables-restore from a script.

-- 
Philip Craig - SnapGear, A CyberGuard Company - http://www.SnapGear.com

[-- Attachment #2: iptables-escape-quote.patch --]
[-- Type: text/plain, Size: 759 bytes --]

Index: iptables-restore.c
===================================================================
--- iptables-restore.c	(revision 3377)
+++ iptables-restore.c	(working copy)
@@ -336,12 +336,15 @@
 			param_start = parsestart;
 			
 			for (curchar = parsestart; *curchar; curchar++) {
+				if (*curchar == '\\' && *(curchar+1) == '"') {
+					if (quote_open) {
+						memmove(curchar, curchar+1,
+							strlen(curchar+1));
+						continue;
+					}
+				}
 				if (*curchar == '"') {
-					/* quote_open cannot be true if there
-					 * was no previous character.  Thus, 
-					 * curchar-1 has to be within bounds */
-					if (quote_open && 
-					    *(curchar-1) != '\\') {
+					if (quote_open) {
 						quote_open = 0;
 						*curchar = ' ';
 					} else {

                 reply	other threads:[~2004-12-20  6:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=41C671DD.2070207@snapgear.com \
    --to=philipc@snapgear.com \
    --cc=netfilter-devel@lists.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 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.