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 */
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to