X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flibsystemd%2Fsd-bus%2Fbus-socket.c;h=c15929c2bbb0755360368d57ef3835b6ddfaed27;hb=2eec67acbb00593e414549a7e5b35eb7dd776b1b;hp=d124d9aa1367902ecd72021d112deefe1793da54;hpb=de0671ee7fe465e108f62dcbbbe9366f81dd9e9a;p=elogind.git diff --git a/src/libsystemd/sd-bus/bus-socket.c b/src/libsystemd/sd-bus/bus-socket.c index d124d9aa1..c15929c2b 100644 --- a/src/libsystemd/sd-bus/bus-socket.c +++ b/src/libsystemd/sd-bus/bus-socket.c @@ -20,16 +20,13 @@ ***/ #include -#include #include #include -#include -#include +#include #include "util.h" #include "macro.h" #include "missing.h" -#include "strv.h" #include "utf8.h" #include "sd-daemon.h" @@ -359,8 +356,7 @@ static int bus_socket_auth_write_ok(sd_bus *b) { assert(b); - snprintf(t, sizeof(t), "OK " SD_ID128_FORMAT_STR "\r\n", SD_ID128_FORMAT_VAL(b->server_id)); - char_array_0(t); + xsprintf(t, "OK " SD_ID128_FORMAT_STR "\r\n", SD_ID128_FORMAT_VAL(b->server_id)); return bus_socket_auth_write(b, t); } @@ -610,10 +606,10 @@ void bus_socket_setup(sd_bus *b) { /* Enable SO_PASSCRED + SO_PASSEC. We try this on any * socket, just in case. */ enable = !b->bus_client; - setsockopt(b->input_fd, SOL_SOCKET, SO_PASSCRED, &enable, sizeof(enable)); + (void)setsockopt(b->input_fd, SOL_SOCKET, SO_PASSCRED, &enable, sizeof(enable)); enable = !b->bus_client && (b->attach_flags & KDBUS_ATTACH_SECLABEL); - setsockopt(b->input_fd, SOL_SOCKET, SO_PASSSEC, &enable, sizeof(enable)); + (void)setsockopt(b->input_fd, SOL_SOCKET, SO_PASSSEC, &enable, sizeof(enable)); /* Increase the buffers to 8 MB */ fd_inc_rcvbuf(b->input_fd, SNDBUF_SIZE); @@ -644,12 +640,11 @@ static int bus_socket_start_auth_client(sd_bus *b) { l = 9; b->auth_buffer = hexmem("anonymous", l); } else { - char text[20 + 1]; /* enough space for a 64bit integer plus NUL */ + char text[DECIMAL_STR_MAX(uid_t) + 1]; auth_prefix = "\0AUTH EXTERNAL "; - snprintf(text, sizeof(text), UID_FMT, geteuid()); - char_array_0(text); + xsprintf(text, UID_FMT, geteuid()); l = strlen(text); b->auth_buffer = hexmem(text, l);