[lttng-dev] [PATCH lttng-tools] Fix: Possible dereference of null pointers

Michael Jeanson mjeanson at efficios.com
Mon Sep 21 16:31:25 EDT 2015


Signed-off-by: Michael Jeanson <mjeanson at efficios.com>
---
 src/common/sessiond-comm/unix.c                      | 6 ++++++
 src/lib/lttng-ctl/filter/filter-visitor-set-parent.c | 4 ++++
 2 files changed, 10 insertions(+)

diff --git a/src/common/sessiond-comm/unix.c b/src/common/sessiond-comm/unix.c
index 4b64161..77a6013 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 91c89dc..f591fd0 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,10 @@ 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:
-- 
1.9.1




More information about the lttng-dev mailing list