diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2015-11-17 16:27:05 +1300 |
---|---|---|
committer | Robert Ancell <robert.ancell@canonical.com> | 2015-11-17 16:27:05 +1300 |
commit | 664bfb1c1f13c6862b9893e6f3ac477ace3f03aa (patch) | |
tree | ee984634afaa55ff174413d4bb936ca213da6318 | |
parent | 0e1fd7f657eb54ab444b7afd83a9c4272c15d49c (diff) | |
download | lightdm-git-664bfb1c1f13c6862b9893e6f3ac477ace3f03aa.tar.gz |
Handle XDMCP Request packet with no addresses
-rw-r--r-- | src/xdmcp-server.c | 5 | ||||
-rw-r--r-- | tests/Makefile.am | 2 | ||||
-rw-r--r-- | tests/scripts/xdmcp-server-request-without-addresses.conf | 31 | ||||
-rwxr-xr-x | tests/test-xdmcp-server-request-without-addresses | 2 |
4 files changed, 39 insertions, 1 deletions
diff --git a/src/xdmcp-server.c b/src/xdmcp-server.c index d1cea2f3..a8ad7769 100644 --- a/src/xdmcp-server.c +++ b/src/xdmcp-server.c @@ -320,6 +320,9 @@ choose_connection (XDMCPPacket *packet, GInetAddress *source_address) gssize index = -1; addresses_length = packet->Request.n_connections; + if (addresses_length == 0) + return NULL; + addresses = malloc (sizeof (GInetAddress *) * addresses_length); for (i = 0; i < addresses_length; i++) addresses[i] = connection_to_address (&packet->Request.connections[i]); @@ -334,7 +337,7 @@ choose_connection (XDMCPPacket *packet, GInetAddress *source_address) index = find_address (addresses, addresses_length, g_inet_address_get_family (source_address)); /* Otherwise use the first available */ - if (index < 0 && addresses_length > 0) + if (index < 0) index = 0; for (i = 0; i < addresses_length; i++) diff --git a/tests/Makefile.am b/tests/Makefile.am index ac696064..c5168ff5 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -165,6 +165,7 @@ TESTS = \ test-xdmcp-client \ test-xdmcp-client-xorg-1.16 \ test-xdmcp-server-login \ + test-xdmcp-server-request-without-addresses \ test-utmp-login \ test-utmp-autologin \ test-utmp-wrong-password \ @@ -563,6 +564,7 @@ EXTRA_DIST = \ scripts/xdmcp-client-xorg-1.16.conf \ scripts/xdmcp-server-login.conf \ scripts/xdmcp-server-open-file-descriptors.conf \ + scripts/xdmcp-server-request-without-addresses.conf \ scripts/xremote-autologin.conf \ scripts/xremote-login.conf \ scripts/xserver-config.conf \ diff --git a/tests/scripts/xdmcp-server-request-without-addresses.conf b/tests/scripts/xdmcp-server-request-without-addresses.conf new file mode 100644 index 00000000..b1604f69 --- /dev/null +++ b/tests/scripts/xdmcp-server-request-without-addresses.conf @@ -0,0 +1,31 @@ +# +# Check remote X server sending a request without connections is ignored +# + +[LightDM] +start-default-seat=false + +[XDMCPServer] +enabled=true +port=9999 + +#?*START-DAEMON +#?RUNNER DAEMON-START +#?*WAIT + +# Start a remote X server to log in with XDMCP +#?*START-XSERVER ARGS=":98 -query 127.0.0.1 -port 9999 -nolisten unix" +#?XSERVER-98 START LISTEN-TCP NO-LISTEN-UNIX + +# Start sending XDMCP queries +#?*XSERVER-98 START-XDMCP +#?XSERVER-98 SEND-QUERY + +# Negotiate with daemon +#?XSERVER-98 GOT-WILLING AUTHENTICATION-NAME="" HOSTNAME="" STATUS="" +#?*XSERVER-98 SEND-REQUEST ADDRESSES="" AUTHORIZATION-NAMES="MIT-MAGIC-COOKIE-1" MFID="TEST XSERVER" +#?XSERVER-98 GOT-DECLINE STATUS="No valid address found" AUTHENTICATION-NAME="" + +# Clean up +#?*STOP-DAEMON +#?RUNNER DAEMON-EXIT STATUS=0 diff --git a/tests/test-xdmcp-server-request-without-addresses b/tests/test-xdmcp-server-request-without-addresses new file mode 100755 index 00000000..ccdcad17 --- /dev/null +++ b/tests/test-xdmcp-server-request-without-addresses @@ -0,0 +1,2 @@ +#!/bin/sh +./src/dbus-env ./src/test-runner xdmcp-server-request-without-addresses test-gobject-greeter |