mirror of
https://github.com/systemd/systemd
synced 2024-10-15 04:24:19 +00:00
cryptsetup: fail with error if extraneous arguments are specified
So far the program would silently ignore those… I think it's better to fail.
This commit is contained in:
parent
166015faf5
commit
5bae80bd44
|
@ -2157,6 +2157,8 @@ static int run(int argc, char *argv[]) {
|
|||
|
||||
if (argc - optind < 3)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "attach requires at least two arguments.");
|
||||
if (argc - optind >= 6)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "attach does not accept more than four arguments.");
|
||||
|
||||
const char *volume = ASSERT_PTR(argv[optind + 1]),
|
||||
*source = ASSERT_PTR(argv[optind + 2]),
|
||||
|
@ -2356,6 +2358,9 @@ static int run(int argc, char *argv[]) {
|
|||
} else if (streq(verb, "detach")) {
|
||||
const char *volume = ASSERT_PTR(argv[optind + 1]);
|
||||
|
||||
if (argc - optind >= 3)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "attach does not accept more than one argument.");
|
||||
|
||||
if (!filename_is_valid(volume))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Volume name '%s' is not valid.", volume);
|
||||
|
||||
|
|
Loading…
Reference in a new issue