X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=liblttng-ust-comm%2Flttng-ust-comm.c;h=d213770f7a25f69059810d14d5f12569636cba2b;hb=f8921d33bfc7f2ec7370b12859064520653ccab0;hp=751ad2e3cf2add1ffd805c9ca4df802034e793b1;hpb=89c5b6ec519764a8311bc4be7544c029f2615d83;p=lttng-ust.git diff --git a/liblttng-ust-comm/lttng-ust-comm.c b/liblttng-ust-comm/lttng-ust-comm.c index 751ad2e3..d213770f 100644 --- a/liblttng-ust-comm/lttng-ust-comm.c +++ b/liblttng-ust-comm/lttng-ust-comm.c @@ -377,6 +377,8 @@ ssize_t ustcomm_send_fds_unix_sock(int sock, int *fds, size_t nb_fd) msg.msg_controllen = CMSG_LEN(sizeof_fds); cmptr = CMSG_FIRSTHDR(&msg); + if (!cmptr) + return -EINVAL; cmptr->cmsg_level = SOL_SOCKET; cmptr->cmsg_type = SCM_RIGHTS; cmptr->cmsg_len = CMSG_LEN(sizeof_fds); @@ -390,7 +392,7 @@ ssize_t ustcomm_send_fds_unix_sock(int sock, int *fds, size_t nb_fd) msg.msg_iovlen = 1; do { - ret = sendmsg(sock, &msg, 0); + ret = sendmsg(sock, &msg, MSG_NOSIGNAL); } while (ret < 0 && errno == EINTR); if (ret < 0) { /* @@ -515,19 +517,27 @@ int ustcomm_recv_app_reply(int sock, struct ustcomm_ust_reply *lur, case 0: /* orderly shutdown */ return -EPIPE; case sizeof(*lur): + { + int err = 0; + if (lur->handle != expected_handle) { ERR("Unexpected result message handle: " "expected: %u vs received: %u\n", expected_handle, lur->handle); - return -EINVAL; + err = 1; } if (lur->cmd != expected_cmd) { ERR("Unexpected result message command " "expected: %u vs received: %u\n", expected_cmd, lur->cmd); + err = 1; + } + if (err) { return -EINVAL; + } else { + return lur->ret_code; } - return lur->ret_code; + } default: if (len >= 0) { ERR("incorrect message size: %zd\n", len);