Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 May 2014 18:09:32 +0000 (UTC)
From:      "Alexander V. Chernikov" <melifaro@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r265693 - stable/10/sbin/ipfw
Message-ID:  <201405081809.s48I9WPs083034@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: melifaro
Date: Thu May  8 18:09:32 2014
New Revision: 265693
URL: http://svnweb.freebsd.org/changeset/base/265693

Log:
  Merge r258677.
  
  Fix key lookup in ipfw(8) broken since r232865.
  Print warning for IPv4 address strings which are valid in
  inet_aton() but not valid in inet_pton(). (1)
  
  Found by:       Özkan KIRIK <ozkan.kirik@gmail.com>
  Submitted by:   Ian Smith <smithi@nimnet.asn.au> (1)

Modified:
  stable/10/sbin/ipfw/ipfw2.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sbin/ipfw/ipfw2.c
==============================================================================
--- stable/10/sbin/ipfw/ipfw2.c	Thu May  8 18:06:44 2014	(r265692)
+++ stable/10/sbin/ipfw/ipfw2.c	Thu May  8 18:09:32 2014	(r265693)
@@ -4274,13 +4274,24 @@ table_fill_xentry(char *arg, ipfw_table_
 			addrlen = sizeof(struct in6_addr);
 		} else {
 			/* Port or any other key */
-			key = strtol(arg, &p, 10);
 			/* Skip non-base 10 entries like 'fa1' */
-			if (p != arg) {
+			key = strtol(arg, &p, 10);
+			if (*p == '\0') {
 				pkey = (uint32_t *)paddr;
 				*pkey = htonl(key);
 				type = IPFW_TABLE_CIDR;
+				masklen = 32;
 				addrlen = sizeof(uint32_t);
+			} else if ((p != arg) && (*p == '.')) {
+				/*
+				 * Warn on IPv4 address strings
+				 * which are "valid" for inet_aton() but not
+				 * in inet_pton().
+				 *
+				 * Typical examples: '10.5' or '10.0.0.05'
+				 */
+				errx(EX_DATAERR,
+				    "Invalid IPv4 address: %s", arg);
 			}
 		}
 	}



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