1 diff -Nur gdm-2.0beta4/daemon/xdmcp.c gdm-2.0beta4.new/daemon/xdmcp.c
2 --- gdm-2.0beta4/daemon/xdmcp.c Thu Sep 30 00:56:35 1999
3 +++ gdm-2.0beta4.new/daemon/xdmcp.c Thu Dec 21 21:51:44 2000
5 int gdm_xdmcp_init (void);
6 void gdm_xdmcp_run (void);
7 void gdm_xdmcp_close (void);
8 -static void gdm_xdmcp_decode_packet (void);
9 +static gboolean gdm_xdmcp_decode_packet (void);
10 static void gdm_xdmcp_handle_query (struct sockaddr_in *clnt_sa, gint len, gint type);
11 static void gdm_xdmcp_send_forward_query (GdmIndirectDisplay *id, ARRAYofARRAY8Ptr authlist);
12 static void gdm_xdmcp_handle_forward_query (struct sockaddr_in *clnt_sa, gint len);
19 gdm_xdmcp_decode_packet (void)
21 struct sockaddr_in clnt_sa;
24 if (!XdmcpFill (xdmcpfd, &buf, &clnt_sa, &sa_len)) {
25 gdm_error (_("gdm_xdmcp_decode: Could not create XDMCP buffer!"));
30 if (!XdmcpReadHeader (&buf, &header)) {
31 gdm_error (_("gdm_xdmcp_decode: Could not read XDMCP header!"));
36 if (header.version != XDM_PROTOCOL_VERSION) {
37 gdm_error (_("gdm_xdmcp_decode: Incorrect XDMCP version!"));
42 gdm_debug ("gdm_xdmcp_decode: Received opcode %s from client %s",
44 inet_ntoa (clnt_sa.sin_addr));
54 /* Read display port */
55 if (! XdmcpReadARRAY8 (&buf, &clnt_port)) {
56 + XdmcpDisposeARRAYofARRAY8 (&clnt_addr);
57 gdm_error (_("gdm_xdmcp_handle_forward_query: Could not read display port number"));
61 /* Extract array of authentication names from Xdmcp packet */
62 if (! XdmcpReadARRAYofARRAY8 (&buf, &clnt_authlist)) {
63 + XdmcpDisposeARRAYofARRAY8 (&clnt_addr);
64 + XdmcpDisposeARRAYofARRAY8 (&clnt_port);
65 gdm_error (_("gdm_xdmcp_handle_forward_query: Could not extract authlist from packet"));
71 gdm_error (_("gdm_xdmcp_handle_forward_query: Error in checksum"));
76 /* Find client port number */
78 port = port*256+clnt_port.data[i];
80 /* Find client address. Ugly, ugly. Endianness sucks... */
81 - memmove (&ia.s_addr, clnt_addr.data, clnt_addr.length);
82 + memmove (&ia.s_addr, clnt_addr.data, MIN(clnt_addr.length, sizeof(ia.s_addr)));
84 gdm_debug ("gdm_xdmcp_handle_forward_query: Got FORWARD_QUERY from display: %s, port %d",
85 inet_ntoa (ia), port);
87 disp_sa->sin_port = htons (port);
88 disp_sa->sin_addr.s_addr = ia.s_addr;
91 - XdmcpDisposeARRAYofARRAY8 (&clnt_authlist);
93 /* Check with tcp_wrappers if display is allowed to access */
94 if (gdm_xdmcp_host_allow (disp_sa))
95 gdm_xdmcp_send_willing (disp_sa);
97 gdm_xdmcp_send_unwilling (disp_sa, FORWARD_QUERY);
102 + XdmcpDisposeARRAYofARRAY8 (&clnt_authlist);
103 + XdmcpDisposeARRAYofARRAY8 (&clnt_port);
104 + XdmcpDisposeARRAYofARRAY8 (&clnt_addr);
109 XdmcpFlush (xdmcpfd, &buf, clnt_sa, sizeof (struct sockaddr_in));
114 gdm_xdmcp_send_unwilling (struct sockaddr_in *clnt_sa, gint type)
116 @@ -540,13 +548,13 @@
118 gdm_xdmcp_handle_request (struct sockaddr_in *clnt_sa, gint len)
120 - static CARD16 clnt_dspnum;
121 - static ARRAY16 clnt_conntyp;
122 - static ARRAYofARRAY8 clnt_addr;
123 - static ARRAY8 clnt_authname;
124 - static ARRAY8 clnt_authdata;
125 - static ARRAYofARRAY8 clnt_authorization;
126 - static ARRAY8 clnt_manufacturer;
127 + CARD16 clnt_dspnum;
128 + ARRAY16 clnt_conntyp;
129 + ARRAYofARRAY8 clnt_addr;
130 + ARRAY8 clnt_authname;
131 + ARRAY8 clnt_authdata;
132 + ARRAYofARRAY8 clnt_authorization;
133 + ARRAY8 clnt_manufacturer;
136 gboolean mitauth = FALSE;
138 gdm_xdmcp_send_accept (clnt_sa, clnt_dspnum);
140 gdm_xdmcp_send_decline (clnt_sa);
142 + XdmcpDisposeARRAY8 (&clnt_authname);
143 + XdmcpDisposeARRAY8 (&clnt_authdata);
144 + XdmcpDisposeARRAY8 (&clnt_manufacturer);
145 + XdmcpDisposeARRAYofARRAY8 (&clnt_addr);
146 + XdmcpDisposeARRAYofARRAY8 (&clnt_authorization);
147 + XdmcpDisposeARRAY16 (&clnt_conntyp);
152 gdm_debug ("gdm_xdmcp_handle_manage: Failed to look up session id %d", clnt_sessid);
153 gdm_xdmcp_send_refuse (clnt_sa, clnt_sessid);
156 + XdmcpDisposeARRAY8(&clnt_dspclass);