Attached is a patch that fixes 3 problems Daniel found in pfctl_table.c Please also make sure you update net/pf_table.c to the latest version (version 9), sorry for that. Cedric
--- pfctl-0.3/pfctl_table.c Wed Jan 1 19:58:07 2003 +++ pfctl-0.4/pfctl_table.c Wed Jan 1 22:54:49 2003 @@ -69,6 +69,7 @@ static void _append_addr(char *, int); static void _print_addr(struct pfr_addr *); static void _print_astats(struct pfr_astats *); +static void _perror(void); static union { @@ -106,7 +107,7 @@ #define DUMMY ((flags & PFR_FLAG_DUMMY)?" (dummy)":"") #define RVTEST(fct) \ do { int rv = fct; if (rv) \ - { perror(__progname); return (1); } \ + { _perror(); return (1); } \ } while (0) int @@ -137,7 +138,7 @@ struct pfr_table table; char **p; int nadd = 0, ndel = 0, nchange = 0, nzero = 0; - int i, rv, flags = 0; + int i, j, flags = 0; for (p = commands; *p != NULL; p++) if (!strncmp(command, *p, strlen(command))) @@ -299,15 +300,19 @@ if (!strcmp(*p, "test")) { _load_addr(argc, argv, file, 1); RVTEST(pfr_tst_addrs(&table, buffer.addrs, size, flags)); - rv = 0; + j = 0; for (i = 0; i < size; i++) { - if (buffer.addrs[i].pfra_fback != PFR_FB_MATCH) - rv = 2; + if (buffer.addrs[i].pfra_fback == PFR_FB_MATCH) + j++; if (opts & PF_OPT_VERBOSE) if ((opts & PF_OPT_VERBOSE2) || buffer.addrs[i].pfra_fback) _print_addr(buffer.addrs+i); } + if (!(opts & PF_OPT_VERBOSE) && !(opts & PF_OPT_QUIET)) + printf("%d/%d addresses match.\n", j, size); + if (j < size) + return (2); } if (!strcmp(*p, "zero")) { if (argc || file != NULL) @@ -324,7 +329,7 @@ void _grow_buffer(int bs, int minsize) { - assert(minsize == 0 || minsize > size); + assert(minsize == 0 || minsize > msize); if (!msize) { msize = minsize; if (msize < 64) @@ -531,4 +536,13 @@ stats_text[dir][op], as->pfras_packets[dir][op], as->pfras_bytes[dir][op]); +} + +void +_perror(void) +{ + if (errno == ESRCH) + fprintf(stderr, "%s: Table does not exist.\n", __progname); + else + perror(__progname); }