diff --git a/sys/netpfil/ipfw/ip_fw_sockopt.c b/sys/netpfil/ipfw/ip_fw_sockopt.c index 8293c34c2169..07630ffa81c5 100644 --- a/sys/netpfil/ipfw/ip_fw_sockopt.c +++ b/sys/netpfil/ipfw/ip_fw_sockopt.c @@ -2535,30 +2535,33 @@ ipfw_del_sopt_handler(struct ipfw_sopt_handler *sh, size_t count) static int ipfw_flush_sopt_data(struct sockopt_data *sd) { -#define RULE_MAXSIZE (512*sizeof(u_int32_t)) + struct sockopt *sopt; int error; size_t sz; - if ((sz = sd->koff) == 0) + sz = sd->koff; + if (sz == 0) return (0); - if (sd->sopt->sopt_dir == SOPT_GET) { - error = sooptcopyout(sd->sopt, sd->kbuf, sz); + sopt = sd->sopt; + + if (sopt->sopt_dir == SOPT_GET) { + error = copyout(sd->kbuf, sopt->sopt_val, sz); if (error != 0) return (error); } memset(sd->kbuf, 0, sd->ksize); - sd->ktotal += sd->koff; + sd->ktotal += sz; sd->koff = 0; if (sd->ktotal + sd->ksize < sd->valsize) sd->kavail = sd->ksize; else sd->kavail = sd->valsize - sd->ktotal; - /* Update sopt buffer */ - sd->sopt->sopt_valsize = sd->ktotal; - sd->sopt->sopt_val = sd->sopt_val + sd->ktotal; + /* Update sopt buffer data */ + sopt->sopt_valsize = sd->ktotal; + sopt->sopt_val = sd->sopt_val + sd->ktotal; return (0); }