Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: mjeanson@efficios.com (Michael Jeanson)
Subject: [lttng-dev] [PATCH lttng-tools] Fix: Possible dereference of null pointers
Date: Mon, 21 Sep 2015 16:31:25 -0400	[thread overview]
Message-ID: <1442867485-15029-1-git-send-email-mjeanson@efficios.com> (raw)

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




             reply	other threads:[~2015-09-21 20:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-21 20:31 Michael Jeanson [this message]
2015-09-21 21:16 ` Jérémie Galarneau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1442867485-15029-1-git-send-email-mjeanson@efficios.com \
    --to=mjeanson@efficios.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox