From 9fa5895bb544b4cb683224ffe61685c75f79482c Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Tue, 17 Jan 2017 17:21:28 +0100 Subject: [PATCH] gpiomon: check if offset is not negative Signed-off-by: Bartosz Golaszewski --- src/tools/gpiomon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tools/gpiomon.c b/src/tools/gpiomon.c index c8157cc..10e7e35 100644 --- a/src/tools/gpiomon.c +++ b/src/tools/gpiomon.c @@ -15,6 +15,7 @@ #include #include #include +#include static const struct option longopts[] = { { "help", no_argument, NULL, 'h' }, @@ -158,7 +159,7 @@ int main(int argc, char **argv) device = argv[0]; offset = strtoul(argv[1], &end, 10); - if (*end != '\0') + if (*end != '\0' || offset > INT_MAX) die("invalid GPIO offset: %s", argv[1]); timeout.tv_sec = 0; -- 2.30.2