From 690dd44121e22b14085cae98eb965ac53ca2f2db Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 24 Nov 2016 10:48:39 +1000 Subject: [PATCH] util: if errno is nonzero, exit early from safe_atoi Signed-off-by: Peter Hutterer (cherry picked from commit 13428f5d82a25c1f56fa247d4a201f805d80fde6) --- src/libinput-util.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libinput-util.h b/src/libinput-util.h index 6c9afdc1..a42643d3 100644 --- a/src/libinput-util.h +++ b/src/libinput-util.h @@ -28,6 +28,7 @@ #include "config.h" #include +#include #include #include #include @@ -410,7 +411,10 @@ safe_atoi(const char *str, int *val) char *endptr; long v; + errno = 0; v = strtol(str, &endptr, 10); + if (errno > 0) + return false; if (str == endptr) return false; if (*str != '\0' && *endptr != '\0')