1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-31 16:21:26 +03:00

dbus-socket: move truncation check to bus_socket_set_transient_property()

This commit is contained in:
Yu Watanabe 2017-12-19 15:30:59 +09:00
parent e045e325df
commit b48e508db3
2 changed files with 7 additions and 4 deletions

View File

@ -381,6 +381,9 @@ static int bus_socket_set_transient_property(
if (r < 0)
return r;
if ((uint64_t) (size_t) t != t)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid %s: %" PRIu64, name, t);
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
if (streq(name, "ReceiveBuffer"))
s->receive_buffer = t;

View File

@ -241,12 +241,12 @@ static int bus_append_parse_sec_rename(sd_bus_message *m, const char *field, con
return 1;
}
static int bus_append_parse_iec_size(sd_bus_message *m, const char *field, const char *eq) {
static int bus_append_parse_size(sd_bus_message *m, const char *field, const char *eq, uint64_t base) {
uint64_t v;
int r;
r = parse_size(eq, 1024, &v);
if (r < 0 || (uint64_t) (size_t) v != v)
r = parse_size(eq, base, &v);
if (r < 0)
return log_error_errno(r, "Failed to parse %s=%s: %m", field, eq);
r = sd_bus_message_append(m, "(sv)", field, "t", v);
@ -1235,7 +1235,7 @@ static int bus_append_socket_property(sd_bus_message *m, const char *field, cons
if (STR_IN_SET(field, "ReceiveBuffer", "SendBuffer", "PipeSize"))
return bus_append_parse_iec_size(m, field, eq);
return bus_append_parse_size(m, field, eq, 1024);
if (STR_IN_SET(field, "ExecStartPre", "ExecStartPost", "ExecReload", "ExecStopPost"))