"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "dbus/dbus-sysdeps-unix.c" between
dbus-1.12.18.tar.gz and dbus-1.12.20.tar.gz

About: D-Bus is an inter-process communication (IPC) system, allowing multiple, concurrently-running applications to communicate with one another. D-Bus supplies both a system daemon and a per-user-login-session daemon.

dbus-sysdeps-unix.c  (dbus-1.12.18):dbus-sysdeps-unix.c  (dbus-1.12.20)
skipping to change at line 444 skipping to change at line 444
{ {
struct cmsghdr *cm; struct cmsghdr *cm;
dbus_bool_t found = FALSE; dbus_bool_t found = FALSE;
for (cm = CMSG_FIRSTHDR(&m); cm; cm = CMSG_NXTHDR(&m, cm)) for (cm = CMSG_FIRSTHDR(&m); cm; cm = CMSG_NXTHDR(&m, cm))
if (cm->cmsg_level == SOL_SOCKET && cm->cmsg_type == SCM_RIGHTS) if (cm->cmsg_level == SOL_SOCKET && cm->cmsg_type == SCM_RIGHTS)
{ {
size_t i; size_t i;
int *payload = (int *) CMSG_DATA (cm); int *payload = (int *) CMSG_DATA (cm);
size_t payload_len_bytes = (cm->cmsg_len - CMSG_LEN (0)); size_t payload_len_bytes = (cm->cmsg_len - CMSG_LEN (0));
size_t payload_len_fds = payload_len_bytes / sizeof (int); size_t payload_len_fds;
size_t fds_to_use; size_t fds_to_use;
/* Every unsigned int fits in a size_t without truncation, so /* Every unsigned int fits in a size_t without truncation, so
* casting (size_t) *n_fds is OK */ * casting (size_t) *n_fds is OK */
_DBUS_STATIC_ASSERT (sizeof (size_t) >= sizeof (unsigned int)); _DBUS_STATIC_ASSERT (sizeof (size_t) >= sizeof (unsigned int));
if ((m.msg_flags & MSG_CTRUNC) && CMSG_NXTHDR(&m, cm) == NULL &&
(char *) payload + payload_len_bytes >
(char *) m.msg_control + m.msg_controllen)
{
/* This is the last cmsg in a truncated message and using
* cmsg_len would apparently overrun the allocated buffer.
* Some operating systems (illumos and Solaris are known) do
* not adjust cmsg_len in the last cmsg when truncation occurs.
* Adjust the payload length here. The calculation for
* payload_len_fds below will discard any trailing bytes that
* belong to an incomplete file descriptor - the kernel will
* have already closed that (at least for illumos and Solaris)
*/
payload_len_bytes = m.msg_controllen -
((char *) payload - (char *) m.msg_control);
}
payload_len_fds = payload_len_bytes / sizeof (int);
if (_DBUS_LIKELY (payload_len_fds <= (size_t) *n_fds)) if (_DBUS_LIKELY (payload_len_fds <= (size_t) *n_fds))
{ {
/* The fds in the payload will fit in our buffer */ /* The fds in the payload will fit in our buffer */
fds_to_use = payload_len_fds; fds_to_use = payload_len_fds;
} }
else else
{ {
/* Too many fds in the payload. This shouldn't happen /* Too many fds in the payload. This shouldn't happen
* any more because we're setting m.msg_controllen to * any more because we're setting m.msg_controllen to
* the exact number we can accept, but be safe and * the exact number we can accept, but be safe and
 End of changes. 2 change blocks. 
1 lines changed or deleted 20 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)