After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 594759 - g_socket_send_message fails due to uninitialised struct msghdr elements
g_socket_send_message fails due to uninitialised struct msghdr elements
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
2.21.x
Other Linux
: Normal major
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2009-09-10 16:22 UTC by James Hunt
Modified: 2009-09-11 12:54 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fix to gio/gsocket.c to rectify invalid sendmsg(2) args. (1.16 KB, patch)
2009-09-10 16:22 UTC, James Hunt
none Details | Review
g_socket_send_message() fails due to invalid sendmsg(2) params. (1.12 KB, patch)
2009-09-11 12:54 UTC, Dan Winship
committed Details | Review

Description James Hunt 2009-09-10 16:22:23 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.
Comment 1 Dan Winship 2009-09-11 12:54:26 UTC
The following fix has been pushed:
1147760 g_socket_send_message() fails due to invalid sendmsg(2) params.

Thanks for the patch.
Comment 2 Dan Winship 2009-09-11 12:54:28 UTC
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.