(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/fdpass.c) |
| |
| 97 | | | ssize_t fd_send(int handle, int send_fd, const void *data, size_t size) |
| 98 | | | { |
| 99 | | | struct msghdr msg; |
| 100 | | | struct iovec iov; |
| 101 | | | struct cmsghdr *cmsg; |
| 102 | | | char buf[CMSG_SPACE(sizeof(int))];
x /usr/include/bits/socket.h |
| |
304 | #define CMSG_SPACE(len) (CMSG_ALIGN (len) \ |
305 | + CMSG_ALIGN (sizeof (struct cmsghdr))) |
| |
x /usr/include/bits/socket.h |
| |
302 | #define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) \ |
303 | & (size_t) ~(sizeof (size_t) - 1)) |
| |
x /usr/include/bits/socket.h |
| |
302 | #define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) \ |
303 | & (size_t) ~(sizeof (size_t) - 1)) |
| |
|
| 103 | | | |
| 104 | | | |
| 105 | | | i_assert(size > 0 && size < INT_MAX);
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/macros.h |
| |
189 | #define i_assert(expr) STMT_START{ \ |
190 | if (unlikely(!(expr))) \ |
191 | i_panic("file %s: line %d (%s): assertion failed: (%s)", \ |
192 | __FILE__, \ |
193 | __LINE__, \ |
194 | __PRETTY_FUNCTION__, \ |
195 | #expr); }STMT_END |
| |
|
| 106 | | | |
| 107 | | | memset(&msg, 0, sizeof(struct msghdr)); |
| 108 | | | |
| 109 | | | iov.iov_base = (void *) data; |
| 110 | | | iov.iov_len = size; |
| 111 | | | |
| 112 | | | msg.msg_iov = &iov; |
| 113 | | | msg.msg_iovlen = 1; |
| 114 | | | |
| 115 | | | if (send_fd != -1) { |
| 116 | | | |
| 117 | | | memset(buf, 0, sizeof(buf)); |
| 118 | | | msg.msg_control = buf; |
| 119 | | | msg.msg_controllen = sizeof(buf); |
| 120 | | | |
| 121 | | | cmsg = CMSG_FIRSTHDR(&msg);
x /usr/include/bits/socket.h |
| |
299 | #define CMSG_FIRSTHDR(mhdr) \ |
300 | ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) \ |
301 | ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0) |
| |
|
| 122 | | | cmsg->cmsg_level = SOL_SOCKET; |
| 123 | | | cmsg->cmsg_type = SCM_RIGHTS;
x /usr/include/bits/socket.h |
| |
338 | #define SCM_RIGHTS SCM_RIGHTS |
| |
|
| 124 | | | cmsg->cmsg_len = CMSG_LEN(sizeof(int));
x /usr/include/bits/socket.h |
| |
306 | #define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len)) |
| |
x /usr/include/bits/socket.h |
| |
302 | #define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) \ |
303 | & (size_t) ~(sizeof (size_t) - 1)) |
| |
|
| 125 | | | *((int *) CMSG_DATA(cmsg)) = send_fd;
x /usr/include/bits/socket.h |
| |
294 | # define CMSG_DATA(cmsg) ((cmsg)->__cmsg_data) |
| |
|
| 126 | | | |
| 127 | | | |
| 128 | | | |
| 129 | | | |
| 130 | | | msg.msg_controllen = cmsg->cmsg_len; |
Useless Assignment
This code assigns the variable the same value it already had. |
|
| 131 | | | } |
| 132 | | | |
| 133 | | | return sendmsg(handle, &msg, 0); |
| 134 | | | } |
| |