From 480566df4841bf0974e10c1f711836a87ea593c7 Mon Sep 17 00:00:00 2001 From: Melissa Eckardt Date: Thu, 20 Nov 2025 17:35:42 +0100 Subject: [PATCH] cflow: Allow overflows for Int64 shifts too The checks were already disabled for Int32. --- de4dot.blocks/cflow/Int32Value.cs | 6 ------ de4dot.blocks/cflow/Int64Value.cs | 6 ------ 2 files changed, 12 deletions(-) diff --git a/de4dot.blocks/cflow/Int32Value.cs b/de4dot.blocks/cflow/Int32Value.cs index 6e8ba8337..b29c74847 100644 --- a/de4dot.blocks/cflow/Int32Value.cs +++ b/de4dot.blocks/cflow/Int32Value.cs @@ -450,8 +450,6 @@ public static Int32Value Shl(Int32Value a, Int32Value b) { return CreateUnknown(); if (b.Value == 0) return a; - //if (b.Value < 0 || b.Value >= sizeof(int) * 8) - // return CreateUnknown(); int shift = b.Value; uint validMask = (a.ValidMask << shift) | (uint.MaxValue >> (sizeof(int) * 8 - shift)); return new Int32Value(a.Value << shift, validMask); @@ -462,8 +460,6 @@ public static Int32Value Shr(Int32Value a, Int32Value b) { return CreateUnknown(); if (b.Value == 0) return a; - //if (b.Value < 0 || b.Value >= sizeof(int) * 8) - // return CreateUnknown(); int shift = b.Value; uint validMask = a.ValidMask >> shift; if (a.IsBitValid(sizeof(int) * 8 - 1)) @@ -476,8 +472,6 @@ public static Int32Value Shr_Un(Int32Value a, Int32Value b) { return CreateUnknown(); if (b.Value == 0) return a; - //if (b.Value < 0 || b.Value >= sizeof(int) * 8) - // return CreateUnknown(); int shift = b.Value; uint validMask = (a.ValidMask >> shift) | (uint.MaxValue << (sizeof(int) * 8 - shift)); return new Int32Value((int)((uint)a.Value >> shift), validMask); diff --git a/de4dot.blocks/cflow/Int64Value.cs b/de4dot.blocks/cflow/Int64Value.cs index bc8b3f087..58a443acc 100644 --- a/de4dot.blocks/cflow/Int64Value.cs +++ b/de4dot.blocks/cflow/Int64Value.cs @@ -393,8 +393,6 @@ public static Int64Value Shl(Int64Value a, Int32Value b) { return CreateUnknown(); if (b.Value == 0) return a; - if (b.Value < 0 || b.Value >= sizeof(long) * 8) - return CreateUnknown(); int shift = b.Value; ulong validMask = (a.ValidMask << shift) | (ulong.MaxValue >> (sizeof(long) * 8 - shift)); return new Int64Value(a.Value << shift, validMask); @@ -405,8 +403,6 @@ public static Int64Value Shr(Int64Value a, Int32Value b) { return CreateUnknown(); if (b.Value == 0) return a; - if (b.Value < 0 || b.Value >= sizeof(long) * 8) - return CreateUnknown(); int shift = b.Value; ulong validMask = a.ValidMask >> shift; if (a.IsBitValid(sizeof(long) * 8 - 1)) @@ -419,8 +415,6 @@ public static Int64Value Shr_Un(Int64Value a, Int32Value b) { return CreateUnknown(); if (b.Value == 0) return a; - if (b.Value < 0 || b.Value >= sizeof(long) * 8) - return CreateUnknown(); int shift = b.Value; ulong validMask = (a.ValidMask >> shift) | (ulong.MaxValue << (sizeof(long) * 8 - shift)); return new Int64Value((long)((ulong)a.Value >> shift), validMask);