summaryrefslogtreecommitdiffstats
path: root/lib/libutil
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2010-08-15 14:50:03 +0000
committerdes <des@FreeBSD.org>2010-08-15 14:50:03 +0000
commit19384270153e149e4f9311215e1b718796d9939d (patch)
tree5043050aaa7dea46b8b9ec4ef1ce38eaf8ef9151 /lib/libutil
parent03b315a9cab9b643c7ce8e5b999b12289c73bfdf (diff)
downloadFreeBSD-src-19384270153e149e4f9311215e1b718796d9939d.zip
FreeBSD-src-19384270153e149e4f9311215e1b718796d9939d.tar.gz
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
Diffstat (limited to 'lib/libutil')
-rw-r--r--lib/libutil/expand_number.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/libutil/expand_number.c b/lib/libutil/expand_number.c
index d1882bd4..9bb0308 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':
OpenPOWER on IntegriCloud