summaryrefslogtreecommitdiffstats
path: root/sbin/ipfw/ipfw2.c
diff options
context:
space:
mode:
authormelifaro <melifaro@FreeBSD.org>2014-05-08 18:09:32 +0000
committermelifaro <melifaro@FreeBSD.org>2014-05-08 18:09:32 +0000
commite9871feb649f1b35fccefcbbf29b7c093f4510d9 (patch)
tree10744cfb643675ff44446bf4fb2f8ed79729f32a /sbin/ipfw/ipfw2.c
parent5b893a150d624da11aa08d7d39cfbe6b752df956 (diff)
downloadFreeBSD-src-e9871feb649f1b35fccefcbbf29b7c093f4510d9.zip
FreeBSD-src-e9871feb649f1b35fccefcbbf29b7c093f4510d9.tar.gz
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)
Diffstat (limited to 'sbin/ipfw/ipfw2.c')
-rw-r--r--sbin/ipfw/ipfw2.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c
index 577d644..196067d 100644
--- a/sbin/ipfw/ipfw2.c
+++ b/sbin/ipfw/ipfw2.c
@@ -4274,13 +4274,24 @@ table_fill_xentry(char *arg, ipfw_table_xentry *xent)
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);
}
}
}
OpenPOWER on IntegriCloud