[glib] g_socket_send_message() fails due to invalid sendmsg(2) params.



commit 11477609d1f2782fd4bbb3022d2ec46983930c6a
Author: James Hunt <jamesodhunt gmail com>
Date:   Thu Sep 10 17:18:13 2009 +0100

    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.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=594759

 gio/gsocket.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/gio/gsocket.c b/gio/gsocket.c
index dd60e03..8e9e07e 100644
--- a/gio/gsocket.c
+++ b/gio/gsocket.c
@@ -2629,6 +2629,11 @@ g_socket_send_message (GSocket                *socket,
 	if (!g_socket_address_to_native (address, msg.msg_name, msg.msg_namelen, error))
 	  return -1;
       }
+    else
+      {
+	msg.msg_name = NULL;
+	msg.msg_namelen = 0;
+      }
 
     /* iov */
     {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]