From: Zbigniew Jędrzejewski-Szmek Date: Sat, 23 Sep 2023 09:59:55 +0000 (+0200) Subject: cryptsetup: fail with error if extraneous arguments are specified X-Git-Tag: v255-rc1~415^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5bae80bd44521084da8aba2512b1b3f22e5e10df;p=thirdparty%2Fsystemd.git cryptsetup: fail with error if extraneous arguments are specified So far the program would silently ignore those… I think it's better to fail. --- 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);