From 5af9f0df3945062eaa8a634039175572ea79fd07 Mon Sep 17 00:00:00 2001 From: Bart De Schuymer Date: Sun, 2 Oct 2005 12:10:48 +0000 Subject: add extra check --- ebtables-restore.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'ebtables-restore.c') diff --git a/ebtables-restore.c b/ebtables-restore.c index c0f9f6b..716ea19 100644 --- a/ebtables-restore.c +++ b/ebtables-restore.c @@ -36,8 +36,8 @@ static void copy_table_names() strcpy(replace[2].name, "broute"); } -#define ebtrest_print_error(format, args...) {fprintf(stderr, "ebtables-restore: "\ - "line %d: "format".\n", line, ##args); exit(-1);} +#define ebtrest_print_error(format, args...) do {fprintf(stderr, "ebtables-restore: "\ + "line %d: "format".\n", line, ##args); exit(-1);} while (0) int main(int argc_, char *argv_[]) { char *argv[EBTD_ARGC_MAX], cmdline[EBTD_CMDLINE_MAXLN]; @@ -73,7 +73,7 @@ int main(int argc_, char *argv_[]) replace[table_nr].flags = OPT_KERNELDATA; /* Prevent do_command from initialising replace */ continue; } else if (table_nr == -1) - ebtrest_print_error("no table specified\n"); + ebtrest_print_error("no table specified"); if (*cmdline == ':') { int policy; char *ch; @@ -90,6 +90,9 @@ int main(int argc_, char *argv_[]) } if (i == NUM_STANDARD_TARGETS) ebtrest_print_error("invalid policy specified"); + /* No need to check chain name for consistency, since + * we're supposed to be reading an automatically generated + * file. */ if (ebt_get_chainnr(&replace[table_nr], cmdline+1) == -1) ebt_new_chain(&replace[table_nr], cmdline+1, policy); continue; @@ -103,6 +106,8 @@ int main(int argc_, char *argv_[]) quotemode ^= 1; if (quotemode) argv[argc++] = &cmdline[offset+1]; + else if (cmdline[offset+1] != ' ' && cmdline[offset+1] != '\0') + ebtrest_print_error("syntax error at \""); cmdline[offset] = '\0'; } else if (!quotemode && cmdline[offset] == ' ') { whitespace = 1; -- cgit v1.2.3