Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Feb 2010 07:39:56 +0000 (UTC)
From:      Luigi Rizzo <luigi@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r203369 - user/luigi/ipfw3-head/sbin/ipfw
Message-ID:  <201002020739.o127duhd012265@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: luigi
Date: Tue Feb  2 07:39:56 2010
New Revision: 203369
URL: http://svn.freebsd.org/changeset/base/203369

Log:
  the man page says inet_pton returns 1 on success and 0 on errors,
  but it does not specify if other return values are possible.
  So be strict and only use 1 as success, instead of anything != 0
  as it was done before (this caused bugs under windows)

Modified:
  user/luigi/ipfw3-head/sbin/ipfw/ipfw2.c

Modified: user/luigi/ipfw3-head/sbin/ipfw/ipfw2.c
==============================================================================
--- user/luigi/ipfw3-head/sbin/ipfw/ipfw2.c	Tue Feb  2 05:57:42 2010	(r203368)
+++ user/luigi/ipfw3-head/sbin/ipfw/ipfw2.c	Tue Feb  2 07:39:56 2010	(r203369)
@@ -2535,11 +2535,11 @@ add_src(ipfw_insn *cmd, char *av, u_char
 		*ch = '\0';
 
 	if (proto == IPPROTO_IPV6  || strcmp(av, "me6") == 0 ||
-	    inet_pton(AF_INET6, host, &a))
+	    inet_pton(AF_INET6, host, &a) == 1)
 		ret = add_srcip6(cmd, av);
 	/* XXX: should check for IPv4, not !IPv6 */
 	if (ret == NULL && (proto == IPPROTO_IP || strcmp(av, "me") == 0 ||
-	    !inet_pton(AF_INET6, host, &a)))
+	    inet_pton(AF_INET6, host, &a) != 1))
 		ret = add_srcip(cmd, av);
 	if (ret == NULL && strcmp(av, "any") != 0)
 		ret = cmd;
@@ -2561,11 +2561,11 @@ add_dst(ipfw_insn *cmd, char *av, u_char
 		*ch = '\0';
 
 	if (proto == IPPROTO_IPV6  || strcmp(av, "me6") == 0 ||
-	    inet_pton(AF_INET6, host, &a))
+	    inet_pton(AF_INET6, host, &a) == 1)
 		ret = add_dstip6(cmd, av);
 	/* XXX: should check for IPv4, not !IPv6 */
 	if (ret == NULL && (proto == IPPROTO_IP || strcmp(av, "me") == 0 ||
-	    !inet_pton(AF_INET6, host, &a)))
+	    inet_pton(AF_INET6, host, &a) != 1))
 		ret = add_dstip(cmd, av);
 	if (ret == NULL && strcmp(av, "any") != 0)
 		ret = cmd;



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