]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: avoid crash when pattern expands to empty unit list
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 24 May 2021 20:49:56 +0000 (22:49 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 25 May 2021 04:29:29 +0000 (13:29 +0900)
Fixes #19652.

src/systemctl/systemctl-edit.c

index 6e7c67ef2f27b54fe82a5b755e56bc8db5d5d934..87650850fe39d79777e1ed3b573dd1b7666759e1 100644 (file)
@@ -526,6 +526,8 @@ int edit(int argc, char *argv[], void *userdata) {
         r = expand_unit_names(bus, strv_skip(argv, 1), NULL, &names, NULL);
         if (r < 0)
                 return log_error_errno(r, "Failed to expand names: %m");
+        if (strv_isempty(names))
+                return log_error_errno(SYNTHETIC_ERRNO(ENOENT), "No units matched the specified patterns.");
 
         STRV_FOREACH(tmp, names) {
                 r = unit_is_masked(bus, &lp, *tmp);