Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Oct 2014 11:21:07 +0000 (UTC)
From:      "Alexander V. Chernikov" <melifaro@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r273327 - head/sys/netpfil/ipfw
Message-ID:  <201410201121.s9KBL7JH096349@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: melifaro
Date: Mon Oct 20 11:21:07 2014
New Revision: 273327
URL: https://svnweb.freebsd.org/changeset/base/273327

Log:
  Use copyout() directly instead of updating various fields
  before/after each sooptcopyout() call.
  
  Found by:	luigi
  Sponsored by:	Yandex LLC

Modified:
  head/sys/netpfil/ipfw/ip_fw_sockopt.c

Modified: head/sys/netpfil/ipfw/ip_fw_sockopt.c
==============================================================================
--- head/sys/netpfil/ipfw/ip_fw_sockopt.c	Mon Oct 20 08:59:30 2014	(r273326)
+++ head/sys/netpfil/ipfw/ip_fw_sockopt.c	Mon Oct 20 11:21:07 2014	(r273327)
@@ -2535,30 +2535,33 @@ ipfw_del_sopt_handler(struct ipfw_sopt_h
 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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201410201121.s9KBL7JH096349>