]> git.ipfire.org Git - thirdparty/ipset.git/commitdiff
Interactive mode error after syntax error (reported by Mart Frauenlob)
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Thu, 21 Feb 2013 11:08:42 +0000 (12:08 +0100)
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Thu, 21 Feb 2013 11:12:54 +0000 (12:12 +0100)
ipset> list foo
ipset v6.16.1: The set with the given name does not exist
ipset> -t
No command specified
ipset> list
ipset v6.16.1: Internal protocol error

In interactive mode the state was not cleaned up properly after a
syntax error, fixed.

src/ipset.c

index 51b912a094e9c807edb395af8080a6860e5b7895..d5ecf7a128e17bd7667fb9e2b2897eb725e84c05 100644 (file)
@@ -563,6 +563,8 @@ parse_commandline(int argc, char *argv[])
        case IPSET_CMD_NONE:
                if (interactive) {
                        printf("No command specified\n");
+                       if (session)
+                               ipset_envopt_parse(session, 0, "reset");
                        return 0;
                }
                if (argc > 1 && STREQ(argv[1], "-")) {
@@ -574,12 +576,15 @@ parse_commandline(int argc, char *argv[])
                                c = cmdline;
                                while (isspace(c[0]))
                                        c++;
-                               if (c[0] == '\0' || c[0] == '#')
+                               if (c[0] == '\0' || c[0] == '#') {
+                                       printf("%s> ", program_name);
                                        continue;
+                               }
                                /* Build fake argv, argc */
                                build_argv(c);
-                               /* Execute line: ignore errors */
-                               parse_commandline(newargc, newargv);
+                               /* Execute line: ignore soft errors */
+                               if (parse_commandline(newargc, newargv) < 0)
+                                       handle_error();
                                printf("%s> ", program_name);
                        }
                        return exit_error(NO_PROBLEM, NULL);