summaryrefslogtreecommitdiff
path: root/cmd/itest.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/itest.c')
-rw-r--r--cmd/itest.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/cmd/itest.c b/cmd/itest.c
index 60626c7fe9..e1896d9f97 100644
--- a/cmd/itest.c
+++ b/cmd/itest.c
@@ -80,7 +80,8 @@ static long evalexp(char *s, int w)
l = simple_strtoul(s, NULL, 16);
}
- return l & ((1UL << (w * 8)) - 1);
+ /* avoid overflow on mask calculus */
+ return (w >= sizeof(long)) ? l : (l & ((1UL << (w * 8)) - 1));
}
static char * evalstr(char *s)