From: David Goulet Date: Fri, 26 Oct 2012 15:48:19 +0000 (-0400) Subject: Fix: missing addrlen initialization before accept(2) X-Git-Tag: v2.1.0-rc6~17 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=88a5db7000bfa9a29be7e843e580aae64e9e7b95;p=lttng-tools.git Fix: missing addrlen initialization before accept(2) Signed-off-by: David Goulet --- diff --git a/src/common/sessiond-comm/inet.c b/src/common/sessiond-comm/inet.c index e8d3afef3..f9ea17dbf 100644 --- a/src/common/sessiond-comm/inet.c +++ b/src/common/sessiond-comm/inet.c @@ -129,7 +129,7 @@ __attribute__((visibility("hidden"))) struct lttcomm_sock *lttcomm_accept_inet_sock(struct lttcomm_sock *sock) { int new_fd; - socklen_t len = 0; + socklen_t len; struct lttcomm_sock *new_sock; if (sock->proto == LTTCOMM_SOCK_UDP) { @@ -145,6 +145,8 @@ struct lttcomm_sock *lttcomm_accept_inet_sock(struct lttcomm_sock *sock) goto error; } + len = sizeof(new_sock->sockaddr.addr.sin); + /* Blocking call */ new_fd = accept(sock->fd, (struct sockaddr *) &new_sock->sockaddr.addr.sin, &len); diff --git a/src/common/sessiond-comm/inet6.c b/src/common/sessiond-comm/inet6.c index 8fe027601..024beace3 100644 --- a/src/common/sessiond-comm/inet6.c +++ b/src/common/sessiond-comm/inet6.c @@ -129,7 +129,7 @@ __attribute__((visibility("hidden"))) struct lttcomm_sock *lttcomm_accept_inet6_sock(struct lttcomm_sock *sock) { int new_fd; - socklen_t len = 0; + socklen_t len; struct lttcomm_sock *new_sock; if (sock->proto == LTTCOMM_SOCK_UDP) { @@ -145,6 +145,8 @@ struct lttcomm_sock *lttcomm_accept_inet6_sock(struct lttcomm_sock *sock) goto error; } + len = sizeof(new_sock->sockaddr.addr.sin6); + /* Blocking call */ new_fd = accept(sock->fd, (struct sockaddr *) &new_sock->sockaddr.addr.sin6, &len);