From c501dabf396e6aeae41869cd2b57809f6d565378 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 13 Sep 2018 08:18:16 +1000 Subject: [PATCH] util: check for < 0 explicitly in safe_atou The previous check only worked if sizeof(long) > sizeof(int). Rather than be fancy about it, just cast to a signed long, check for negativity and continue based on that. Fixes #137 Signed-off-by: Peter Hutterer --- src/libinput-util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libinput-util.h b/src/libinput-util.h index ff8d56fb..360e3906 100644 --- a/src/libinput-util.h +++ b/src/libinput-util.h @@ -538,7 +538,7 @@ safe_atou_base(const char *str, unsigned int *val, int base) if (*str != '\0' && *endptr != '\0') return false; - if (v > UINT_MAX) + if ((long)v < 0) return false; *val = v;