From 5bae80bd44521084da8aba2512b1b3f22e5e10df Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sat, 23 Sep 2023 11:59:55 +0200 Subject: [PATCH] cryptsetup: fail with error if extraneous arguments are specified MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit So far the program would silently ignore those… I think it's better to fail. --- src/cryptsetup/cryptsetup.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c index 5e283a7dd09..a7577d8113b 100644 --- a/src/cryptsetup/cryptsetup.c +++ b/src/cryptsetup/cryptsetup.c @@ -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); -- 2.47.3