Commit b6a34399 authored by Niels Möller's avatar Niels Möller
Browse files

(CMSG_LEN): Fallback definition now includes

int alignment at the end of the header.
(pty_recv_message): Check that msg_controllen is large enough
before using CMSG_FIRSTHDR.

Rev: src/pty-helper.c:1.12
parent 7ae7bc64
......@@ -47,8 +47,8 @@
/* At least Solaris 5.8 lacks CMSG_LEN and CMSG_SPACE. */
#ifndef CMSG_LEN
/* The safest way seems to be to extract the offset of the data */
# define CMSG_LEN(l) ((size_t) CMSG_DATA((struct cmsghdr *) 0) + (l))
# define CMSG_LEN(l) \
(((sizeof(struct cmsghdr) + sizeof(int) - 1) & ~(sizeof(int) - 1)) + (l))
#endif
#ifndef CMSG_SPACE
......@@ -221,6 +221,9 @@ pty_recv_message(int socket, struct pty_message *message)
return -1;
/* Process any ancillary data before examining the regular data */
/* On SunOS 5.8, CMSG_FIRSTHDR doesn't handle empty lists correctly */
if (hdr.msg_controllen >= sizeof(struct cmsghdr))
for (cmsg = CMSG_FIRSTHDR(&hdr); cmsg; cmsg = CMSG_NXTHDR(&hdr, cmsg))
{
if (cmsg->cmsg_level != SOL_SOCKET)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment