The previous comparison with LONG_{MIN,MAX} was (almost) always false
because the variable for the comparison had already been casted from
long to int.Signed-off-by: Michael Adler <[email protected]> --- tools/bg_setenv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/bg_setenv.c b/tools/bg_setenv.c index d26eeed..043c0aa 100644 --- a/tools/bg_setenv.c +++ b/tools/bg_setenv.c @@ -221,16 +221,17 @@ static error_t set_uservars(char *arg) static int parse_int(char *arg) { char *tmp; - int i; + long i; errno = 0; i = strtol(arg, &tmp, 10); if ((errno == ERANGE && (i == LONG_MAX || i == LONG_MIN)) || + (i > INT_MAX || i < INT_MIN) || (errno != 0 && i == 0) || (tmp == arg)) { errno = EINVAL; return -1; } - return i; + return (int) i; } static error_t parse_opt(int key, char *arg, struct argp_state *state) -- 2.33.0 -- You received this message because you are subscribed to the Google Groups "EFI Boot Guard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/efibootguard-dev/20211008075125.614591-1-michael.adler%40siemens.com.
