diff options
author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2010-08-15 14:50:03 +0000 |
---|---|---|
committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2010-08-15 14:50:03 +0000 |
commit | 1035d74025de93515f0a7baf2c48eed25e854099 (patch) | |
tree | 5043050aaa7dea46b8b9ec4ef1ce38eaf8ef9151 /lib/libutil/expand_number.c | |
parent | 6d4317a1e4c1b6197de2b0ebb6b81358955b78d9 (diff) | |
download | src-1035d74025de93515f0a7baf2c48eed25e854099.tar.gz src-1035d74025de93515f0a7baf2c48eed25e854099.zip |
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
Notes
Notes:
svn path=/head/; revision=211337
Diffstat (limited to 'lib/libutil/expand_number.c')
-rw-r--r-- | lib/libutil/expand_number.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/libutil/expand_number.c b/lib/libutil/expand_number.c index d1882bd4c067..9bb0308d1415 100644 --- a/lib/libutil/expand_number.c +++ b/lib/libutil/expand_number.c @@ -67,7 +67,7 @@ expand_number(const char *buf, uint64_t *num) } #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': |