924N/Adiff --git a/xdmcp.c b/xdmcp.c
924N/Aindex 7c91d1e..66a5e0f 100644
924N/A--- a/xdmcp.c
924N/A+++ b/xdmcp.c
924N/A@@ -791,8 +791,8 @@ forward_respond (
924N/A {
924N/A struct sockaddr_in6 in6_addr;
924N/A
924N/A- if (clientAddress.length != 16 ||
924N/A- clientPort.length != 2)
924N/A+ if ((clientAddress.length != 16 && clientAddress.length != 4) ||
924N/A+ (clientPort.length != 2))
924N/A {
924N/A goto badAddress;
924N/A }
924N/A@@ -801,7 +801,24 @@ forward_respond (
924N/A in6_addr.sin6_len = sizeof(in6_addr);
924N/A # endif
924N/A in6_addr.sin6_family = AF_INET6;
924N/A- memmove(&in6_addr.sin6_addr,clientAddress.data,clientAddress.length);
924N/A+ if (clientAddress.length == 16) {
924N/A+ memmove(in6_addr.sin6_addr.s6_addr, clientAddress.data, 16);
924N/A+ } else {
924N/A+ /* If the client wants to forward the xdm server to an
924N/A+ ipv4 hosts it sends an ipv4 address in the forward
924N/A+ packet. On dual-stack hosts the packet arrives as a
924N/A+ ipv6 packet. To respond to the ipv4 host one has
924N/A+ to create an ipv4-mapped address of the form
924N/A+
924N/A+ ::ffff::xxx.xxx.xxx.xxx
924N/A+
924N/A+ One example where this is necessary is an ipv4-only
924N/A+ thin client that connects to a dual-stacked xdm.
924N/A+ */
924N/A+ in6_addr.sin6_addr.s6_addr[10] = 0xff;
924N/A+ in6_addr.sin6_addr.s6_addr[11] = 0xff;
924N/A+ memmove(in6_addr.sin6_addr.s6_addr + 12, clientAddress.data, 4);
924N/A+ }
924N/A memmove((char *) &in6_addr.sin6_port, clientPort.data, 2);
924N/A client = (struct sockaddr *) &in6_addr;
924N/A clientlen = sizeof (in6_addr);
924N/A