summaryrefslogtreecommitdiff
path: root/src/systemctl
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-10-01 14:27:20 +0200
committerLennart Poettering <lennart@poettering.net>2015-10-01 14:27:20 +0200
commit7e9d36e06b85d87eb2c3aed507fe3aa1574c7880 (patch)
treedbc982dad39c4b09425c3ce0daea01f931249d7d /src/systemctl
parent3d3145100d77a059b145a488df3d31763fdf1920 (diff)
systemctl: fix how we decode types and states
There was a bad memory access among other smaller issues.
Diffstat (limited to 'src/systemctl')
-rw-r--r--src/systemctl/systemctl.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 0615dd6aa5..420a246be1 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -6648,7 +6648,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
}
if (unit_type_from_string(type) >= 0) {
- if (strv_push(&arg_types, type))
+ if (strv_push(&arg_types, type) < 0)
return log_oom();
type = NULL;
continue;
@@ -6658,7 +6658,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
* load states, but let's support this
* in --types= too for compatibility
* with old versions */
- if (unit_load_state_from_string(optarg) >= 0) {
+ if (unit_load_state_from_string(type) >= 0) {
if (strv_push(&arg_states, type) < 0)
return log_oom();
type = NULL;
@@ -6871,8 +6871,10 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
return 0;
}
- if (strv_consume(&arg_states, s) < 0)
+ if (strv_push(&arg_states, s) < 0)
return log_oom();
+
+ s = NULL;
}
break;
}