mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
dmsetup: validate strtol reading
Better validation for --mode option.
This commit is contained in:
parent
47b7d4a733
commit
962874bfe2
@ -7054,7 +7054,13 @@ static int _process_switches(int *argcp, char ***argvp, const char *dev_dir)
|
||||
if (c == 'M' || ind == MODE_ARG) {
|
||||
_switches[MODE_ARG]++;
|
||||
/* FIXME Accept modes as per chmod */
|
||||
_int_args[MODE_ARG] = (int) strtol(optarg, NULL, 8);
|
||||
errno = 0;
|
||||
_int_args[MODE_ARG] = (int) strtol(optarg, &s, 8);
|
||||
if (errno || !s || *s || !_int_args[MODE_ARG]) {
|
||||
log_error("Invalid argument for --mode: %s. %s",
|
||||
optarg, errno ? strerror(errno) : "");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (ind == DEFERRED_ARG)
|
||||
_switches[DEFERRED_ARG]++;
|
||||
|
Loading…
Reference in New Issue
Block a user