From: Michael Jeanson Date: Mon, 21 Sep 2015 20:31:25 +0000 (-0400) Subject: Fix: Possible dereference of null pointers X-Git-Tag: v2.8.0-rc1~310 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=1d8d032800b64945d90c7b5a7b8e9316e733a4b1;p=lttng-tools.git Fix: Possible dereference of null pointers Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau --- diff --git a/src/common/sessiond-comm/unix.c b/src/common/sessiond-comm/unix.c index 4b6416168..77a6013f0 100644 --- a/src/common/sessiond-comm/unix.c +++ b/src/common/sessiond-comm/unix.c @@ -281,6 +281,9 @@ ssize_t lttcomm_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 -1; + } cmptr->cmsg_level = SOL_SOCKET; cmptr->cmsg_type = SCM_RIGHTS; cmptr->cmsg_len = CMSG_LEN(sizeof_fds); @@ -408,6 +411,9 @@ ssize_t lttcomm_send_creds_unix_sock(int sock, void *buf, size_t len) msg.msg_controllen = CMSG_LEN(sizeof_cred); cmptr = CMSG_FIRSTHDR(&msg); + if (!cmptr) { + return -1; + } cmptr->cmsg_level = SOL_SOCKET; cmptr->cmsg_type = LTTNG_SOCK_CREDS; cmptr->cmsg_len = CMSG_LEN(sizeof_cred); diff --git a/src/lib/lttng-ctl/filter/filter-visitor-set-parent.c b/src/lib/lttng-ctl/filter/filter-visitor-set-parent.c index 91c89dccb..458688da4 100644 --- a/src/lib/lttng-ctl/filter/filter-visitor-set-parent.c +++ b/src/lib/lttng-ctl/filter/filter-visitor-set-parent.c @@ -36,6 +36,11 @@ int update_child(struct filter_node *parent, struct filter_node *old_child, struct filter_node *new_child) { + if (!parent) { + fprintf(stderr, "[error] %s: NULL parent\n", __func__); + return -EINVAL; + } + switch (parent->type) { case NODE_UNKNOWN: default: