mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-09-20 01:06:15 +02:00
gsocket: Work around broken CMSG_FIRSTHDR()
As RFC 2292 points out, some platforms (e.g. Darwin 9.8.0) provide CMSG_FIRSTHDR(msg) which just returns msg.msg_control without first checking if msg.msg_controllen is non-zero. We need a workaround for such platforms not to let g_socket_receive_message() segfault. https://bugzilla.gnome.org/show_bug.cgi?id=690388
This commit is contained in:
parent
780871d273
commit
f0f6c8d231
@ -4154,6 +4154,8 @@ g_socket_receive_message (GSocket *socket,
|
||||
GPtrArray *my_messages = NULL;
|
||||
struct cmsghdr *cmsg;
|
||||
|
||||
if (msg.msg_controllen >= sizeof (struct cmsghdr))
|
||||
{
|
||||
for (cmsg = CMSG_FIRSTHDR (&msg); cmsg; cmsg = CMSG_NXTHDR (&msg, cmsg))
|
||||
{
|
||||
GSocketControlMessage *message;
|
||||
@ -4181,6 +4183,7 @@ g_socket_receive_message (GSocket *socket,
|
||||
g_ptr_array_add (my_messages, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (num_messages)
|
||||
*num_messages = my_messages != NULL ? my_messages->len : 0;
|
||||
|
Loading…
Reference in New Issue
Block a user