Skip to content

Commit ec21785

Browse files
committed
Handle XDMCP Request packet with no addresses
1 parent 59b8d00 commit ec21785

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

src/xdmcp-server.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,9 @@ choose_connection (XDMCPPacket *packet, GInetAddress *source_address)
363363
gssize index = -1;
364364

365365
addresses_length = packet->Request.n_connections;
366+
if (addresses_length == 0)
367+
return NULL;
368+
366369
addresses = malloc (sizeof (GInetAddress *) * addresses_length);
367370
for (i = 0; i < addresses_length; i++)
368371
addresses[i] = connection_to_address (&packet->Request.connections[i]);
@@ -377,7 +380,7 @@ choose_connection (XDMCPPacket *packet, GInetAddress *source_address)
377380
index = find_address (addresses, addresses_length, g_inet_address_get_family (source_address));
378381

379382
/* Otherwise use the first available */
380-
if (index < 0 && addresses_length > 0)
383+
if (index < 0)
381384
index = 0;
382385

383386
for (i = 0; i < addresses_length; i++)

tests/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ TESTS = \
179179
test-xdmcp-server-login \
180180
test-xdmcp-server-double-login \
181181
test-xdmcp-server-guest \
182+
test-xdmcp-server-request-without-addresses \
182183
test-utmp-login \
183184
test-utmp-autologin \
184185
test-utmp-wrong-password \
@@ -599,6 +600,7 @@ EXTRA_DIST = \
599600
scripts/xdmcp-server-guest.conf \
600601
scripts/xdmcp-server-login.conf \
601602
scripts/xdmcp-server-open-file-descriptors.conf \
603+
scripts/xdmcp-server-request-without-addresses.conf \
602604
scripts/xremote-autologin.conf \
603605
scripts/xremote-login.conf \
604606
scripts/xserver-config.conf \
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#
2+
# Check remote X server sending a request without connections is ignored
3+
#
4+
5+
[LightDM]
6+
start-default-seat=false
7+
8+
[XDMCPServer]
9+
enabled=true
10+
11+
[test-xserver-config]
12+
xdcmp-empty-request=true
13+
14+
#?*START-DAEMON
15+
#?RUNNER DAEMON-START
16+
#?*WAIT
17+
18+
# Start a remote X server to log in with XDMCP
19+
#?*START-XSERVER ARGS=":98 -query 127.0.0.1 -nolisten unix"
20+
#?XSERVER-98 START LISTEN-TCP NO-LISTEN-UNIX
21+
22+
# Start sending XDMCP queries
23+
#?*XSERVER-98 START-XDMCP
24+
#?XSERVER-98 SEND-QUERY
25+
26+
# Negotiate with daemon
27+
#?XSERVER-98 GOT-WILLING AUTHENTICATION-NAME="" HOSTNAME="" STATUS=""
28+
#?*XSERVER-98 SEND-REQUEST ADDRESSES="" AUTHORIZATION-NAMES="MIT-MAGIC-COOKIE-1" MFID="TEST XSERVER"
29+
#?XSERVER-98 GOT-DECLINE STATUS="No valid address found" AUTHENTICATION-NAME=""
30+
31+
# Clean up
32+
#?*STOP-DAEMON
33+
#?RUNNER DAEMON-EXIT STATUS=0
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
./src/dbus-env ./src/test-runner xdmcp-server-request-without-addresses test-gobject-greeter

0 commit comments

Comments
 (0)