Fix: Possible dereference of null pointers
authorMichael Jeanson <mjeanson@efficios.com>
Mon, 21 Sep 2015 20:31:25 +0000 (16:31 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 21 Sep 2015 21:08:06 +0000 (17:08 -0400)
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/sessiond-comm/unix.c
src/lib/lttng-ctl/filter/filter-visitor-set-parent.c

index 4b6416168afa9f465406dd4bcce73d5d129180fe..77a6013f0244572b2c2bb30ae054959db2cdf5c4 100644 (file)
@@ -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);
index 91c89dccb81b633463a0169d18af0d187530b25d..458688da44a13b4d924be20162b7d15e46f575eb 100644 (file)
@@ -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:
This page took 0.026453 seconds and 4 git commands to generate.