summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bootctl/bootctl.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/bootctl/bootctl.c b/bootctl/bootctl.c
index 55eb5bf4..58fdbb69 100644
--- a/bootctl/bootctl.c
+++ b/bootctl/bootctl.c
@@ -132,13 +132,14 @@ static int parse_slot(int pos, int argc, char *argv[])
exit(EX_USAGE);
return -1;
}
- int ret = strtol(argv[pos], NULL, 10);
- if (ret == LONG_MIN || ret == LONG_MAX) {
+ errno = 0;
+ long int ret = strtol(argv[pos], NULL, 10);
+ if (errno != 0 || ret > INT_MAX || ret < 0) {
usage(stderr, argc, argv);
exit(EX_USAGE);
return -1;
}
- return ret;
+ return (int)ret;
}
int main(int argc, char *argv[])