Merge pull request #416 from eeff/eeff/dev

Fix command line `--restart` option number conversion
This commit is contained in:
fengzeroz
2022-04-11 11:29:54 +08:00
committed by GitHub
+6 -3
View File
@@ -76,9 +76,12 @@ static inline size_t parse_restart_policy(const char *s, size_t *out)
} else if (0 == strcmp(s, "on-failure")) {
*out = NEU_RESTART_ONFAILURE;
} else {
errno = 0;
uintmax_t n = strtoumax(s, NULL, 0);
if (0 != errno || n > NEU_RESTART_ALWAYS) {
errno = 0;
char * end = NULL;
uintmax_t n = strtoumax(s, &end, 0);
// the entire string should be a number within range
if (0 != errno || '\0' == *s || '\0' != *end ||
n > NEU_RESTART_ALWAYS) {
return -1;
}
*out = n;