chiark / gitweb /
systemctl: check the argument to -t for invalid values
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 6 Jun 2012 14:56:19 +0000 (16:56 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 10 Jul 2012 15:07:32 +0000 (17:07 +0200)
Systemctl accepted anything as the argument for -t, and simply said '0
units found'. It is better to catch this user error early.

src/systemctl/systemctl.c

index c89920b..a968179 100644 (file)
@@ -4650,6 +4650,10 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
                         return 0;
 
                 case 't':
+                        if (unit_type_from_string(optarg) < 0) {
+                                log_error("Invalid unit type '%s'.", optarg);
+                                return -EINVAL;
+                        }
                         arg_type = optarg;
                         break;