Commit 08ff37d0 authored by Andreas Fett's avatar Andreas Fett Committed by Adam Jackson

os/xdmcp: Fix binding of ipv6 source address

Choose the socket fd of the correct address family based
on the address family of the argument to the -from option.

Fixes: #4
parent 96e00730
Pipeline #6704 passed with stage
in 3 minutes and 56 seconds
......@@ -912,6 +912,7 @@ static void
get_xdmcp_sock(void)
{
int soopts = 1;
int socketfd = -1;
#if defined(IPv6) && defined(AF_INET6)
if ((xdmcpSocket6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
......@@ -924,8 +925,18 @@ get_xdmcp_sock(void)
sizeof(soopts)) < 0)
XdmcpWarning("UDP set broadcast socket-option failed");
#endif /* SO_BROADCAST */
if (xdmcpSocket >= 0 && xdm_from != NULL) {
if (bind(xdmcpSocket, (struct sockaddr *) &FromAddress,
if (xdm_from == NULL)
return;
if (SOCKADDR_FAMILY(FromAddress) == AF_INET)
socketfd = xdmcpSocket;
#if defined(IPv6) && defined(AF_INET6)
else if (SOCKADDR_FAMILY(FromAddress) == AF_INET6)
socketfd = xdmcpSocket6;
#endif
if (socketfd >= 0) {
if (bind(socketfd, (struct sockaddr *) &FromAddress,
FromAddressLen) < 0) {
FatalError("Xserver: failed to bind to -from address: %s\n",
xdm_from);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment