From 507ce6782cdb711b4c41d36c884b8d2ca48cb29a Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Fri, 12 Apr 2024 16:38:43 +0200 Subject: [PATCH] Fix bug 4786 "remove type confusion in getsockopt call in sock_connect_async_cb" The function getsockopt expects a pointer to an area of memory whose length has to specified in a variable of type socklen_t. Adjust the type of optlen to be socklen_t as mandated by POSIX. Adjust the type of optval pointer to what it really is, it will be automatically converted to become a void * pointer. Signed-off-by: Olaf Hering --- src/common/socket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/socket.c b/src/common/socket.c index e9d50184b..a63c9a7a8 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -709,7 +709,7 @@ static gboolean sock_connect_async_cb(GIOChannel *source, SockConnectData *conn_data = (SockConnectData *)data; gint fd; gint val; - guint len; + socklen_t len; SockInfo *sockinfo; if (conn_data->io_tag == 0 && conn_data->channel == NULL) @@ -722,7 +722,7 @@ static gboolean sock_connect_async_cb(GIOChannel *source, g_io_channel_unref(source); len = sizeof(val); - if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)&val, &len) < 0) { + if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &val, &len) < 0) { perror("getsockopt"); close(fd); sock_connect_address_list_async(conn_data); -- 2.11.4.GIT