--- sbin/ipfw/ipfw2.c.orig 2017-04-10 20:47:20.140177000 +0700 +++ sbin/ipfw/ipfw2.c 2017-05-01 19:23:29.097139000 +0700 @@ -3176,7 +3176,6 @@ ipfw_delete(char *av[]) av++; NEED1("missing rule specification"); - memset(&rt, 0, sizeof(rt)); if ( *av && _substrcmp(*av, "set") == 0) { /* Do not allow using the following syntax: * ipfw set N delete set M @@ -3189,6 +3188,7 @@ ipfw_delete(char *av[]) /* Rule number */ while (*av && isdigit(**av)) { + memset(&rt, 0, sizeof(rt)); i = strtol(*av, &sep, 10); j = i; if (*sep== '-') @@ -5124,12 +5124,11 @@ ipfw_zero(int ac, char *av[], int optnam char const *name = optname ? "RESETLOG" : "ZERO"; optname = optname ? IP_FW_XRESETLOG : IP_FW_XZERO; - memset(&rt, 0, sizeof(rt)); - av++; ac--; if (ac == 0) { /* clear all entries */ + memset(&rt, 0, sizeof(rt)); rt.flags = IPFW_RCFLAG_ALL; if (do_range_cmd(optname, &rt) < 0) err(EX_UNAVAILABLE, "setsockopt(IP_FW_X%s)", name); @@ -5147,6 +5146,7 @@ ipfw_zero(int ac, char *av[], int optnam if (errstr) errx(EX_DATAERR, "invalid rule number %s\n", *av); + memset(&rt, 0, sizeof(rt)); rt.start_rule = arg; rt.end_rule = arg; rt.flags |= IPFW_RCFLAG_RANGE;