projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: Possible dereference of null pointers
[lttng-tools.git]
/
src
/
common
/
sessiond-comm
/
unix.c
diff --git
a/src/common/sessiond-comm/unix.c
b/src/common/sessiond-comm/unix.c
index 2c87b82c451f87de02fb5db074cb24a32c752696..77a6013f0244572b2c2bb30ae054959db2cdf5c4 100644
(file)
--- a/
src/common/sessiond-comm/unix.c
+++ b/
src/common/sessiond-comm/unix.c
@@
-17,6
+17,7
@@
*/
#define _GNU_SOURCE
*/
#define _GNU_SOURCE
+#define _LGPL_SOURCE
#include <assert.h>
#include <limits.h>
#include <stdio.h>
#include <assert.h>
#include <limits.h>
#include <stdio.h>
@@
-92,6
+93,16
@@
int lttcomm_accept_unix_sock(int sock)
return new_fd;
}
return new_fd;
}
+LTTNG_HIDDEN
+int lttcomm_create_anon_unix_socketpair(int *fds)
+{
+ if (socketpair(PF_UNIX, SOCK_STREAM, 0, fds) < 0) {
+ PERROR("socketpair");
+ return -1;
+ }
+ return 0;
+}
+
/*
* Creates a AF_UNIX local socket using pathname bind the socket upon creation
* and return the fd.
/*
* Creates a AF_UNIX local socket using pathname bind the socket upon creation
* and return the fd.
@@
-172,7
+183,7
@@
ssize_t lttcomm_recv_unix_sock(int sock, void *buf, size_t len)
do {
len_last = iov[0].iov_len;
do {
len_last = iov[0].iov_len;
- ret = recvmsg(sock, &msg,
0
);
+ ret = recvmsg(sock, &msg,
MSG_NOSIGNAL
);
if (ret > 0) {
iov[0].iov_base += ret;
iov[0].iov_len -= ret;
if (ret > 0) {
iov[0].iov_base += ret;
iov[0].iov_len -= ret;
@@
-270,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);
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);
cmptr->cmsg_level = SOL_SOCKET;
cmptr->cmsg_type = SCM_RIGHTS;
cmptr->cmsg_len = CMSG_LEN(sizeof_fds);
@@
-397,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);
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);
cmptr->cmsg_level = SOL_SOCKET;
cmptr->cmsg_type = LTTNG_SOCK_CREDS;
cmptr->cmsg_len = CMSG_LEN(sizeof_cred);
This page took
0.026161 seconds
and
4
git commands to generate.