From: Jarkko Korpi Subject: [PATCH v3] widl: Fix overflow when left-shifting Message-Id: Date: Tue, 21 Jun 2016 07:16:12 +0000 Signed-off-by: Jarkko Korpi Based on the analyze of bug https://bugs.winehq.org/show_bug.cgi?id=38962 Resent since the tool name is incorrect. Another resend since no patch title in previous patch. = From c007df9746d0d6ba388ad9b9a32df7390c601fc6 Mon Sep 17 00:00:00 2001 From: Jarkko Korpi Date: Tue, 21 Jun 2016 09:23:22 +0300 Subject: [PATCH] widl: Fix overflow when left-shifting --- tools/widl/expr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/widl/expr.c b/tools/widl/expr.c index 0ada012..9ac76c8 100644 --- a/tools/widl/expr.c +++ b/tools/widl/expr.c @@ -222,7 +222,7 @@ expr_t *make_exprt(enum expr_type type, var_t *var, expr_t *expr) e->is_const = TRUE; if (is_signed_integer_type(tref)) { - cast_mask = (1 << (cast_type_bits - 1)) - 1; + cast_mask = (1u << (cast_type_bits - 1)) - 1; if (expr->cval & (1 << (cast_type_bits - 1))) e->cval = -((-expr->cval) & cast_mask); else @@ -231,8 +231,8 @@ expr_t *make_exprt(enum expr_type type, var_t *var, expr_t *expr) else { /* calculate ((1 << cast_type_bits) - 1) avoiding overflow */ - cast_mask = ((1 << (cast_type_bits - 1)) - 1) | - 1 << (cast_type_bits - 1); + cast_mask = ((1u << (cast_type_bits - 1)) - 1) | + 1u << (cast_type_bits - 1); e->cval = expr->cval & cast_mask; } } -- 1.9.1