mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-03-06 12:58:22 +03:00
core: fix property getter method for NFileDescriptorStore bus property
Since da6053d0a7c16795e7fac1f9ba6694863918a597 this is a size_t, not an unsigned. The difference doesn't matter on LE archs, but it matters on BE (i.e. s390x), since we'll return entirely nonsensical data. Let's fix that. Follow-up-for: da6053d0a7c16795e7fac1f9ba6694863918a597 An embarassing bug introduced in 2018... That made me scratch my head for way too long, as it made #27135 fail on s390x while it passed everywhere else. (cherry picked from commit 47226e893b24f1aa84caaa6be266fb3c03442904)
This commit is contained in:
parent
eec30e3143
commit
a25e2ef992
@ -217,6 +217,29 @@ int bus_service_method_mount_image(sd_bus_message *message, void *userdata, sd_b
|
||||
return bus_service_method_mount(message, userdata, error, true);
|
||||
}
|
||||
|
||||
#if __SIZEOF_SIZE_T__ == 8
|
||||
static int property_get_size_as_uint32(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
size_t *value = ASSERT_PTR(userdata);
|
||||
uint32_t sz = *value >= UINT32_MAX ? UINT32_MAX : (uint32_t) *value;
|
||||
|
||||
/* Returns a size_t as a D-Bus "u" type, i.e. as 32bit value, even if size_t is 64bit. We'll saturate if it doesn't fit. */
|
||||
|
||||
return sd_bus_message_append_basic(reply, 'u', &sz);
|
||||
}
|
||||
#elif __SIZEOF_SIZE_T__ == 4
|
||||
#define property_get_size_as_uint32 ((sd_bus_property_get_t) NULL)
|
||||
#else
|
||||
#error "Unexpected size of size_t"
|
||||
#endif
|
||||
|
||||
const sd_bus_vtable bus_service_vtable[] = {
|
||||
SD_BUS_VTABLE_START(0),
|
||||
SD_BUS_PROPERTY("Type", "s", property_get_type, offsetof(Service, type), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
@ -245,7 +268,7 @@ const sd_bus_vtable bus_service_vtable[] = {
|
||||
SD_BUS_PROPERTY("ControlPID", "u", bus_property_get_pid, offsetof(Service, control_pid), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
||||
SD_BUS_PROPERTY("BusName", "s", NULL, offsetof(Service, bus_name), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_PROPERTY("FileDescriptorStoreMax", "u", bus_property_get_unsigned, offsetof(Service, n_fd_store_max), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_PROPERTY("NFileDescriptorStore", "u", bus_property_get_unsigned, offsetof(Service, n_fd_store), 0),
|
||||
SD_BUS_PROPERTY("NFileDescriptorStore", "u", property_get_size_as_uint32, offsetof(Service, n_fd_store), 0),
|
||||
SD_BUS_PROPERTY("StatusText", "s", NULL, offsetof(Service, status_text), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
||||
SD_BUS_PROPERTY("StatusErrno", "i", bus_property_get_int, offsetof(Service, status_errno), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
||||
SD_BUS_PROPERTY("Result", "s", property_get_result, offsetof(Service, result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
||||
|
Loading…
x
Reference in New Issue
Block a user