* Zero rule buffer.

* Rename 'read' variable.

Pointed by:	luigi
This commit is contained in:
Alexander V. Chernikov 2014-10-18 15:18:31 +00:00
parent e17bdf9f1b
commit 6ff33bb6aa
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=273253

View File

@ -2530,7 +2530,7 @@ ipfw_show_config(struct cmdline_opts *co, struct format_opts *fo,
int lac; int lac;
char **lav; char **lav;
char *endptr; char *endptr;
size_t read; size_t readsz;
struct buf_pr bp; struct buf_pr bp;
ipfw_obj_ctlv *ctlv, *tstate; ipfw_obj_ctlv *ctlv, *tstate;
ipfw_obj_tlv *rbase; ipfw_obj_tlv *rbase;
@ -2542,7 +2542,7 @@ ipfw_show_config(struct cmdline_opts *co, struct format_opts *fo,
rbase = NULL; rbase = NULL;
dynbase = NULL; dynbase = NULL;
dynsz = 0; dynsz = 0;
read = sizeof(*cfg); readsz = sizeof(*cfg);
rcnt = 0; rcnt = 0;
fo->set_mask = cfg->set_mask; fo->set_mask = cfg->set_mask;
@ -2553,7 +2553,7 @@ ipfw_show_config(struct cmdline_opts *co, struct format_opts *fo,
/* We've requested static rules */ /* We've requested static rules */
if (ctlv->head.type == IPFW_TLV_TBLNAME_LIST) { if (ctlv->head.type == IPFW_TLV_TBLNAME_LIST) {
fo->tstate = ctlv; fo->tstate = ctlv;
read += ctlv->head.length; readsz += ctlv->head.length;
ctlv = (ipfw_obj_ctlv *)((caddr_t)ctlv + ctlv = (ipfw_obj_ctlv *)((caddr_t)ctlv +
ctlv->head.length); ctlv->head.length);
} }
@ -2561,15 +2561,15 @@ ipfw_show_config(struct cmdline_opts *co, struct format_opts *fo,
if (ctlv->head.type == IPFW_TLV_RULE_LIST) { if (ctlv->head.type == IPFW_TLV_RULE_LIST) {
rbase = (ipfw_obj_tlv *)(ctlv + 1); rbase = (ipfw_obj_tlv *)(ctlv + 1);
rcnt = ctlv->count; rcnt = ctlv->count;
read += ctlv->head.length; readsz += ctlv->head.length;
ctlv = (ipfw_obj_ctlv *)((caddr_t)ctlv + ctlv = (ipfw_obj_ctlv *)((caddr_t)ctlv +
ctlv->head.length); ctlv->head.length);
} }
} }
if ((cfg->flags & IPFW_CFG_GET_STATES) && (read != sz)) { if ((cfg->flags & IPFW_CFG_GET_STATES) && (readsz != sz)) {
/* We may have some dynamic states */ /* We may have some dynamic states */
dynsz = sz - read; dynsz = sz - readsz;
/* Skip empty header */ /* Skip empty header */
if (dynsz != sizeof(ipfw_obj_ctlv)) if (dynsz != sizeof(ipfw_obj_ctlv))
dynbase = (caddr_t)ctlv; dynbase = (caddr_t)ctlv;
@ -4686,6 +4686,7 @@ ipfw_add(char *av[])
ipfw_obj_ctlv *ctlv, *tstate; ipfw_obj_ctlv *ctlv, *tstate;
rbufsize = sizeof(rulebuf); rbufsize = sizeof(rulebuf);
memset(rulebuf, 0, rbufsize);
memset(&ts, 0, sizeof(ts)); memset(&ts, 0, sizeof(ts));
/* Optimize case with no tables */ /* Optimize case with no tables */