Skip to contentSkip to conversation

Fix: Possible dereference of null pointers

PATCH Jérémie Galarneau 1 participant 1 message Sep 21, 2015 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Merged in master and stable-2.7, thanks!

Jérémie

Quoted 48 lines · Michael Jeanson
---
 src/common/sessiond-comm/unix.c                      | 6 ++++++
 src/lib/lttng-ctl/filter/filter-visitor-set-parent.c | 4 ++++
 2 files changed, 10 insertions(+)
src/common/sessiond-comm/unix.c +6 -0
index 4b64161..77a6013 100644
@@ -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);
src/lib/lttng-ctl/filter/filter-visitor-set-parent.c +4 -1
index 91c89dc..f591fd0 100644
@@ -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

Signature · 8 lines
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev