1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-12 09:17:44 +03:00

tty-ask-password-agent: assing sendto() result to a ssize_t variable, not an int

We should be careful with these types, and if we do convert between
"int" and "ssize_t" we should do so explicitly rather than implicitly.
Otherwise this just looks like a bug.
This commit is contained in:
Lennart Poettering 2018-02-13 23:53:59 +01:00
parent 87964ec7d1
commit 5439206bc7

View File

@ -254,6 +254,7 @@ static int send_passwords(const char *socket_name, char **passwords) {
union sockaddr_union sa = { .un.sun_family = AF_UNIX }; union sockaddr_union sa = { .un.sun_family = AF_UNIX };
size_t packet_length = 1; size_t packet_length = 1;
char **p, *d; char **p, *d;
ssize_t n;
int r; int r;
assert(socket_name); assert(socket_name);
@ -279,9 +280,13 @@ static int send_passwords(const char *socket_name, char **passwords) {
strncpy(sa.un.sun_path, socket_name, sizeof(sa.un.sun_path)); strncpy(sa.un.sun_path, socket_name, sizeof(sa.un.sun_path));
r = sendto(socket_fd, packet, packet_length, MSG_NOSIGNAL, &sa.sa, SOCKADDR_UN_LEN(sa.un)); n = sendto(socket_fd, packet, packet_length, MSG_NOSIGNAL, &sa.sa, SOCKADDR_UN_LEN(sa.un));
if (r < 0) if (n < 0) {
r = log_debug_errno(errno, "sendto(): %m"); r = log_debug_errno(errno, "sendto(): %m");
goto finish;
}
r = (int) n;
finish: finish:
explicit_bzero(packet, packet_length); explicit_bzero(packet, packet_length);