swapon: do not use atoi()
Addresses: https://github.com/karelzak/util-linux/issues/1358 Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
e4aad0a9c4
commit
878307e960
|
@ -722,9 +722,15 @@ static int parse_options(struct swap_prop *props, const char *options)
|
||||||
}
|
}
|
||||||
|
|
||||||
arg = NULL;
|
arg = NULL;
|
||||||
if (mnt_optstr_get_option(options, "pri", &arg, NULL) == 0 && arg)
|
if (mnt_optstr_get_option(options, "pri", &arg, &argsz) == 0 && arg) {
|
||||||
props->priority = atoi(arg);
|
char *end = NULL;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
n = (int) strtol(arg, &end, 10);
|
||||||
|
if (errno == 0 && end && end > arg)
|
||||||
|
props->priority = n;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue