gpiomon: check if offset is not negative
authorBartosz Golaszewski <bartekgola@gmail.com>
Tue, 17 Jan 2017 16:21:28 +0000 (17:21 +0100)
committerBartosz Golaszewski <bartekgola@gmail.com>
Tue, 17 Jan 2017 16:21:28 +0000 (17:21 +0100)
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
src/tools/gpiomon.c

index c8157cc02d538c98e481aada9a3dcf74503585c2..10e7e355181b411ce8de2a604691b553e3487227 100644 (file)
@@ -15,6 +15,7 @@
 #include <string.h>
 #include <getopt.h>
 #include <signal.h>
+#include <limits.h>
 
 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;