summaryrefslogtreecommitdiffstats
path: root/src/shared
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-07-28 11:55:49 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-07-29 15:54:53 +0200
commit62b21e2e89b68f0a1fb209e6677c61fdb4c32b34 (patch)
tree935b513d366d3f000e082e021fda87a93411de53 /src/shared
parentbus-util: convert bus_log_{parse,create}_error into defines (diff)
downloadsystemd-62b21e2e89b68f0a1fb209e6677c61fdb4c32b34.tar.xz
systemd-62b21e2e89b68f0a1fb209e6677c61fdb4c32b34.zip
shared/bus-util: fix dbus serialization of {RestartPrevent,RestartForce,Success}ExitStatus
We were passing 1/4th of the size in bytes as argument. So depending on the size of the array, either we'd only transfer a subset of values, or we'd get an alignment error.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/bus-unit-util.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c
index 322204dd22..99511d338a 100644
--- a/src/shared/bus-unit-util.c
+++ b/src/shared/bus-unit-util.c
@@ -1439,7 +1439,7 @@ static int bus_append_service_property(sd_bus_message *m, const char *field, con
if (STR_IN_SET(field, "RestartPreventExitStatus", "RestartForceExitStatus", "SuccessExitStatus")) {
_cleanup_free_ int *status = NULL, *signal = NULL;
- size_t sz_status = 0, sz_signal = 0;
+ size_t n_status = 0, n_signal = 0;
const char *p;
for (p = eq;;) {
@@ -1460,17 +1460,17 @@ static int bus_append_service_property(sd_bus_message *m, const char *field, con
if (val < 0)
return log_error_errno(r, "Invalid status or signal %s in %s: %m", word, field);
- signal = reallocarray(signal, sz_signal + 1, sizeof(int));
+ signal = reallocarray(signal, n_signal + 1, sizeof(int));
if (!signal)
return log_oom();
- signal[sz_signal++] = val;
+ signal[n_signal++] = val;
} else {
- status = reallocarray(status, sz_status + 1, sizeof(int));
+ status = reallocarray(status, n_status + 1, sizeof(int));
if (!status)
return log_oom();
- status[sz_status++] = val;
+ status[n_status++] = val;
}
}
@@ -1490,11 +1490,11 @@ static int bus_append_service_property(sd_bus_message *m, const char *field, con
if (r < 0)
return bus_log_create_error(r);
- r = sd_bus_message_append_array(m, 'i', status, sz_status);
+ r = sd_bus_message_append_array(m, 'i', status, n_status * sizeof(int));
if (r < 0)
return bus_log_create_error(r);
- r = sd_bus_message_append_array(m, 'i', signal, sz_signal);
+ r = sd_bus_message_append_array(m, 'i', signal, n_signal * sizeof(int));
if (r < 0)
return bus_log_create_error(r);