mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09: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:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user