mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
tree-wide: be more careful when passing literal integers to "t" bus message fields
Since we use varargs for sd_message_append() we need to make sure the parameters we pass are actually 64bit wide, if "t" is used. Hence cast appropriately if necessary. I went through the whole tree, and in most cases we got it right, but there are some cases we missed so far. Inspired by: #31420
This commit is contained in:
committed by
Yu Watanabe
parent
ff80bd2d6d
commit
04a3af3c6d
@@ -492,7 +492,7 @@ static int property_get_bind_paths(
|
||||
c->bind_mounts[i].source,
|
||||
c->bind_mounts[i].destination,
|
||||
c->bind_mounts[i].ignore_enoent,
|
||||
c->bind_mounts[i].recursive ? (uint64_t) MS_REC : (uint64_t) 0);
|
||||
c->bind_mounts[i].recursive ? (uint64_t) MS_REC : UINT64_C(0));
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
@@ -911,7 +911,7 @@ static int bus_property_get_exec_dir_symlink(
|
||||
|
||||
for (size_t i = 0; i < d->n_items; i++)
|
||||
STRV_FOREACH(dst, d->items[i].symlinks) {
|
||||
r = sd_bus_message_append(reply, "(sst)", d->items[i].path, *dst, 0 /* flags, unused for now */);
|
||||
r = sd_bus_message_append(reply, "(sst)", d->items[i].path, *dst, UINT64_C(0) /* flags, unused for now */);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ static int property_get_open_files(
|
||||
return r;
|
||||
|
||||
LIST_FOREACH(open_files, of, *open_files) {
|
||||
r = sd_bus_message_append(reply, "(sst)", of->path, of->fdname, of->flags);
|
||||
r = sd_bus_message_append(reply, "(sst)", of->path, of->fdname, (uint64_t) of->flags);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -1239,7 +1239,7 @@ static int property_get_cgroup_id(
|
||||
assert(reply);
|
||||
|
||||
CGroupRuntime *crt = unit_get_cgroup_runtime(u);
|
||||
return sd_bus_message_append(reply, "t", crt ? crt->cgroup_id : 0);
|
||||
return sd_bus_message_append(reply, "t", crt ? crt->cgroup_id : UINT64_C(0));
|
||||
}
|
||||
|
||||
static int append_process(sd_bus_message *reply, const char *p, PidRef *pid, Set *pids) {
|
||||
|
||||
@@ -1130,7 +1130,7 @@ static int copy_files(int argc, char *argv[], void *userdata) {
|
||||
return bus_log_create_error(r);
|
||||
|
||||
if (arg_force) {
|
||||
r = sd_bus_message_append(m, "t", MACHINE_COPY_REPLACE);
|
||||
r = sd_bus_message_append(m, "t", (uint64_t) MACHINE_COPY_REPLACE);
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
}
|
||||
|
||||
@@ -1171,7 +1171,7 @@ static int is_image_attached(int argc, char *argv[], void *userdata) {
|
||||
return r;
|
||||
|
||||
if (!strv_isempty(arg_extension_images)) {
|
||||
r = sd_bus_message_append(m, "t", 0);
|
||||
r = sd_bus_message_append(m, "t", UINT64_C(0));
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
}
|
||||
|
||||
@@ -1419,12 +1419,12 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to parse resource limit: %s", eq);
|
||||
|
||||
r = sd_bus_message_append(m, "(sv)", field, "t", l.rlim_max);
|
||||
r = sd_bus_message_append(m, "(sv)", field, "t", (uint64_t) l.rlim_max);
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
sn = strjoina(field, "Soft");
|
||||
r = sd_bus_message_append(m, "(sv)", sn, "t", l.rlim_cur);
|
||||
r = sd_bus_message_append(m, "(sv)", sn, "t", (uint64_t) l.rlim_cur);
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
@@ -2167,7 +2167,7 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
|
||||
return bus_log_create_error(r);
|
||||
|
||||
STRV_FOREACH_PAIR(source, destination, symlinks) {
|
||||
r = sd_bus_message_append(m, "(sst)", *source, *destination, 0);
|
||||
r = sd_bus_message_append(m, "(sst)", *source, *destination, UINT64_C(0));
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user