From 2db029c857fb0b3b566c97fe2fa5e0077ae41741 Mon Sep 17 00:00:00 2001 From: Jozsef Kadlecsik Date: Thu, 21 Feb 2013 12:08:42 +0100 Subject: Interactive mode error after syntax error (reported by Mart Frauenlob) 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 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/ipset.c') diff --git a/src/ipset.c b/src/ipset.c index 51b912a..d5ecf7a 100644 --- a/src/ipset.c +++ b/src/ipset.c @@ -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); -- cgit v1.2.3