From 37c56b2bd1f6a59af7ef6c88e7d2cbc7e747602f Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 14 Apr 2003 18:34:27 -0700 Subject: Peter points out that the type masking shifts can overflow if sizeof(long long) == sizeof(long) (and furter if it's also the same size as 'int', all perfectly legal C). Fix it by his suggestion. --- expression.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/expression.c b/expression.c index bc36563..6658312 100644 --- a/expression.c +++ b/expression.c @@ -123,12 +123,12 @@ static void get_int_value(struct expression *expr, const char *str) bits = BITS_IN_LONGLONG; extramod = 0; if (!(modifiers & MOD_LONGLONG)) { - if (value & (~0ULL << BITS_IN_LONG)) { + if (value & (~1ULL << (BITS_IN_LONG-1))) { extramod = MOD_LONGLONG | MOD_LONG; } else { bits = BITS_IN_LONG; if (!(modifiers & MOD_LONG)) { - if (value & (~0ULL << BITS_IN_INT)) { + if (value & (~1ULL << (BITS_IN_INT-1))) { extramod = MOD_LONG; } else bits = BITS_IN_INT; -- cgit v1.2.3-65-gdbad