X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=cmd%2Fitest.c;h=fd6f4166f16cf1dad96a681892ce5f96b3fc0352;hb=f37770c7707b9c11e1832005392a3b049b9fdf14;hp=60626c7fe9c3d983d247aeee6f89b76548a189b5;hpb=d77fa2ff766bbb4b867e791187f78b6033071613;p=oweals%2Fu-boot.git diff --git a/cmd/itest.c b/cmd/itest.c index 60626c7fe9..fd6f4166f1 100644 --- a/cmd/itest.c +++ b/cmd/itest.c @@ -1,8 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * (C) Copyright 2003 * Tait Electronics Limited, Christchurch, New Zealand - * - * SPDX-License-Identifier: GPL-2.0+ */ /* @@ -80,7 +79,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) @@ -100,7 +100,7 @@ static char * evalstr(char *s) i++; } s[i] = 0; - return getenv((const char *)&s[2]); + return env_get((const char *)&s[2]); } else { return s; }