Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Aug 2015 21:07:58 +0000 (UTC)
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r286702 - head/sbin/ipfw
Message-ID:  <201508122107.t7CL7w47035212@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dim
Date: Wed Aug 12 21:07:57 2015
New Revision: 286702
URL: https://svnweb.freebsd.org/changeset/base/286702

Log:
  In ipfw2, avoid left-shifting negative integers, which is undefined.
  While here, make some other arguments to htonl(3) unsigned too.
  
  MFC after:	3 days

Modified:
  head/sbin/ipfw/ipfw2.c

Modified: head/sbin/ipfw/ipfw2.c
==============================================================================
--- head/sbin/ipfw/ipfw2.c	Wed Aug 12 20:50:20 2015	(r286701)
+++ head/sbin/ipfw/ipfw2.c	Wed Aug 12 21:07:57 2015	(r286702)
@@ -2869,14 +2869,14 @@ fill_ip(ipfw_insn_ip *cmd, char *av, int
 	case '/':
 		masklen = atoi(p);
 		if (masklen == 0)
-			d[1] = htonl(0);	/* mask */
+			d[1] = htonl(0U);	/* mask */
 		else if (masklen > 32)
 			errx(EX_DATAERR, "bad width ``%s''", p);
 		else
-			d[1] = htonl(~0 << (32 - masklen));
+			d[1] = htonl(~0U << (32 - masklen));
 		break;
 	case '{':	/* no mask, assume /24 and put back the '{' */
-		d[1] = htonl(~0 << (32 - 24));
+		d[1] = htonl(~0U << (32 - 24));
 		*(--p) = md;
 		break;
 
@@ -2885,7 +2885,7 @@ fill_ip(ipfw_insn_ip *cmd, char *av, int
 		/* FALLTHROUGH */
 	case 0:		/* initialization value */
 	default:
-		d[1] = htonl(~0);	/* force /32 */
+		d[1] = htonl(~0U);	/* force /32 */
 		break;
 	}
 	d[0] &= d[1];		/* mask base address with mask */



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