Bug 1084342: Copy received ancillary data into |SocketMessageWatcher|, r=shawnjohnjr

The cast-and-assign pattern for retrieving file descriptors is prone to
SIGBUS signals on platforms that don't support unaligned memory access.
This patch fixes the problem by copying the received data directly.
This commit is contained in:
Thomas Zimmermann 2014-10-28 10:34:29 +01:00
Родитель 5c750e1803
Коммит 9133e20f81
2 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -232,7 +232,7 @@ SocketMessageWatcher::RecvMsg2()
TEMP_FAILURE_RETRY(close(mClientFd));
}
// retrieve sent client fd
mClientFd = *(static_cast<int*>(CMSG_DATA(cmsgptr)));
memcpy(&mClientFd, CMSG_DATA(cmsgptr), sizeof(mClientFd));
}
}

Просмотреть файл

@ -232,7 +232,7 @@ SocketMessageWatcher::RecvMsg2()
TEMP_FAILURE_RETRY(close(mClientFd));
}
// retrieve sent client fd
mClientFd = *(static_cast<int*>(CMSG_DATA(cmsgptr)));
memcpy(&mClientFd, CMSG_DATA(cmsgptr), sizeof(mClientFd));
}
}