Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Oct 2014 12:54:56 +0000 (UTC)
From:      "Alexander V. Chernikov" <melifaro@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r272818 - projects/ipfw/sbin/ipfw
Message-ID:  <201410091254.s99Csuh1068065@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: melifaro
Date: Thu Oct  9 12:54:56 2014
New Revision: 272818
URL: https://svnweb.freebsd.org/changeset/base/272818

Log:
  * Fix use-after-free in table printing code.
  * Fix showing human-readable error in table cmds code.

Modified:
  projects/ipfw/sbin/ipfw/tables.c

Modified: projects/ipfw/sbin/ipfw/tables.c
==============================================================================
--- projects/ipfw/sbin/ipfw/tables.c	Thu Oct  9 12:37:53 2014	(r272817)
+++ projects/ipfw/sbin/ipfw/tables.c	Thu Oct  9 12:54:56 2014	(r272818)
@@ -1018,6 +1018,8 @@ table_modify_record(ipfw_obj_header *oh,
 
 	if (error == 0)
 		return;
+	/* Get real OS error */
+	error = errno;
 
 	/* Try to provide more human-readable error */
 	switch (error) {
@@ -1551,12 +1553,11 @@ tables_foreach(table_cb_t *f, void *arg,
 
 		olh->size = sz;
 		if (do_get3(IP_FW_TABLES_XLIST, &olh->opheader, &sz) != 0) {
+			sz = olh->size;
 			free(olh);
-			if (errno == ENOMEM) {
-				sz = olh->size;
-				continue;
-			}
-			return (errno);
+			if (errno != ENOMEM)
+				return (errno);
+			continue;
 		}
 
 		if (sort != 0)



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