From: Andrei Emeltchenko <andrei.emeltchenko@xxxxxxxxx> Make code cleaner and initialize local cmsg buffer to zeroes. --- android/socket.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/android/socket.c b/android/socket.c index 5f89f2c..22472b9 100644 --- a/android/socket.c +++ b/android/socket.c @@ -394,7 +394,7 @@ static int bt_sock_send_fd(int sock_fd, const void *buf, int len, int send_fd) struct msghdr msg; struct cmsghdr *cmsg; struct iovec iv; - char msgbuf[CMSG_SPACE(1)]; + char cmsgbuf[CMSG_SPACE(sizeof(int))]; DBG("len %d sock_fd %d send_fd %d", len, sock_fd, send_fd); @@ -402,13 +402,16 @@ static int bt_sock_send_fd(int sock_fd, const void *buf, int len, int send_fd) return -1; memset(&msg, 0, sizeof(msg)); + memset(cmsgbuf, 0, sizeof(cmsgbuf)); + + msg.msg_control = cmsgbuf; + msg.msg_controllen = sizeof(cmsgbuf); - msg.msg_control = msgbuf; - msg.msg_controllen = sizeof(msgbuf); cmsg = CMSG_FIRSTHDR(&msg); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_RIGHTS; cmsg->cmsg_len = CMSG_LEN(sizeof(send_fd)); + memcpy(CMSG_DATA(cmsg), &send_fd, sizeof(send_fd)); iv.iov_base = (unsigned char *) buf; -- 1.8.3.2 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html