From 1d8d032800b64945d90c7b5a7b8e9316e733a4b1 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Mon, 21 Sep 2015 16:31:25 -0400 Subject: [PATCH] Fix: Possible dereference of null pointers MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau --- src/common/sessiond-comm/unix.c | 6 ++++++ src/lib/lttng-ctl/filter/filter-visitor-set-parent.c | 5 +++++ 2 files changed, 11 insertions(+) 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: -- 2.34.1