GNOME Bugzilla – Bug 594759
g_socket_send_message fails due to uninitialised struct msghdr elements
Last modified: 2009-09-11 12:54:28 UTC
Created attachment 142921 [details] [review] fix to gio/gsocket.c to rectify invalid sendmsg(2) args. g_socket_send_message() and g_socket_send_to() in the GIO part of GLib fail with ENOBUFS or EFAULT due to the fact that if no "address" argument is specified to g_socket_send_message, when g_socket_send_message() calls sendmsg(2), the 2nd parameter to sendmsg ("const struct msghdr *msg") contains uninitialized values. The fix is simple - initialize msg.msg_name to NULL and msg.msg_msg_namelen to 0. Tested with Unix domain sockets on Ubuntu Jaunty with kernel 2.6.28-15-generic.
The following fix has been pushed: 1147760 g_socket_send_message() fails due to invalid sendmsg(2) params. Thanks for the patch.
Created attachment 142978 [details] [review] g_socket_send_message() fails due to invalid sendmsg(2) params. g_socket_send_message() and g_socket_send_to() fail with ENOBUFS or EFAULT due to the fact that if no "address" argument is specified to g_socket_send_message, when g_socket_send_message() calls sendmsg(2), the 2nd parameter to sendmsg ("const struct msghdr *msg") contains uninitialized values. The fix is simple - initialize msg.msg_name to NULL and msg.msg_msg_namelen to 0.