Author: des
Date: Sun Aug 15 14:50:03 2010
New Revision: 211337
URL: http://svn.freebsd.org/changeset/base/211337

Log:
  Fix the overflow test.  It is possible for the result of an
  overflowing shift to be larger than the original value, e.g.
  
           (uint64_t)1 << 53 = 0x20000000000000
   ((uint64_t)1 << 53) << 10 = 0x8000000000000000

Modified:
  head/lib/libutil/expand_number.c

Modified: head/lib/libutil/expand_number.c
==============================================================================
--- head/lib/libutil/expand_number.c    Sun Aug 15 14:44:48 2010        
(r211336)
+++ head/lib/libutil/expand_number.c    Sun Aug 15 14:50:03 2010        
(r211337)
@@ -67,7 +67,7 @@ expand_number(const char *buf, uint64_t 
        }
 
 #define SHIFT(n, b)                                                    \
-       do { if ((n << b) < n) goto overflow; n <<= b; } while (0)
+       do { if (((n << b) >> b) != n) goto overflow; n <<= b; } while (0)
 
        switch (tolower((unsigned char)*endptr)) {
        case 'e':
_______________________________________________
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