It is perfectly legal to specify an empty argument using two double
quotes, e.g. '--log-prefix ""'. Fix the parser in add_param_to_argv() to
detect this situation and not treat it like double spaces.

Signed-off-by: Phil Sutter <p...@nwl.cc>
---
 iptables/xtables-restore.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/iptables/xtables-restore.c b/iptables/xtables-restore.c
index 17d4bc75e92de..fe4db32bbe637 100644
--- a/iptables/xtables-restore.c
+++ b/iptables/xtables-restore.c
@@ -119,7 +119,7 @@ static void add_param_to_argv(char *parsestart)
                                continue;
                        } else if (*curchar == '"') {
                                quote_open = 0;
-                               *curchar = ' ';
+                               *curchar = '"';
                        } else {
                                param_buffer[param_len++] = *curchar;
                                continue;
@@ -132,9 +132,10 @@ static void add_param_to_argv(char *parsestart)
                }
 
                if (*curchar == ' '
+                   || *curchar == '"'
                    || *curchar == '\t'
                    || * curchar == '\n') {
-                       if (!param_len) {
+                       if (!param_len && *curchar != '"') {
                                /* two spaces? */
                                continue;
                        }
-- 
2.18.0

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to