View | Details | Raw Unified | Return to bug 625593
Collapse All | Expand All

(-)xorg-server-1.8.0/os/access.c (-17 lines)
Lines 800-817 Link Here
800
	    )
800
	    )
801
		continue;
801
		continue;
802
802
803
	    /* 
804
	     * ignore 'localhost' entries as they're not useful
805
	     * on the other end of the wire
806
	     */
807
	    if (ifr->ifa_flags & IFF_LOOPBACK) 
808
		    continue;
809
810
	    if (family == FamilyInternet && 
811
		addr[0] == 127 && addr[1] == 0 &&
812
		addr[2] == 0 && addr[3] == 1) 
813
		continue;
814
815
	    /*
803
	    /*
816
	     * Ignore '0.0.0.0' entries as they are
804
	     * Ignore '0.0.0.0' entries as they are
817
	     * returned by some OSes for unconfigured NICs but they are
805
	     * returned by some OSes for unconfigured NICs but they are
Lines 821-831 Link Here
821
		addr[0] == 0 && addr[1] == 0 &&
809
		addr[0] == 0 && addr[1] == 0 &&
822
		addr[2] == 0 && addr[3] == 0)
810
		addr[2] == 0 && addr[3] == 0)
823
		continue;
811
		continue;
824
#if defined(IPv6) && defined(AF_INET6)
825
	    else if (family == FamilyInternet6 && 
826
	      IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr))
827
		continue;
828
#endif
829
	    XdmcpRegisterConnection(family, (char *)addr, len);
812
	    XdmcpRegisterConnection(family, (char *)addr, len);
830
#if defined(IPv6) && defined(AF_INET6)
813
#if defined(IPv6) && defined(AF_INET6)
831
	    if (family == FamilyInternet6) 
814
	    if (family == FamilyInternet6) 
(-)xorg-server-1.8.0/os/xdmcp.c (-33 / +94 lines)
Lines 27-32 Link Here
27
#include <sys/param.h>
27
#include <sys/param.h>
28
#include <sys/socket.h>
28
#include <sys/socket.h>
29
#include <netinet/in.h>
29
#include <netinet/in.h>
30
#include <arpa/inet.h>
30
#include <netdb.h>
31
#include <netdb.h>
31
#endif
32
#endif
32
33
Lines 209-214 Link Here
209
210
210
static ARRAY8 ManufacturerDisplayID;
211
static ARRAY8 ManufacturerDisplayID;
211
212
213
214
215
static int is_loopback(int type, void *a)
216
{
217
  char *addr = a;
218
  int ret = 0;
219
  int gairet;
220
  struct sockaddr_storage s;
221
  struct sockaddr_in *s4 = (struct sockaddr_in *)&s;
222
  struct sockaddr_in6 *s6 = (struct sockaddr_in6 *)&s;
223
  char host[NI_MAXHOST];
224
225
  memset(&s, 0, sizeof(s));
226
  if (type == FamilyInternet) {
227
    s4->sin_family = AF_INET;
228
    s4->sin_addr.s_addr = *((in_addr_t*)a);
229
    if (addr[0] == 127) {
230
      /* IPv4 loopback /8 net */
231
      ret = 1;
232
    }
233
  } else if (type == FamilyInternet6) {
234
    s6->sin6_family = AF_INET6;
235
    memcpy(&(s6->sin6_addr), a, sizeof(struct in6_addr));
236
    if (IN6_IS_ADDR_LOOPBACK(addr)) {
237
      /* IPv6 loopback address */
238
      ret = 1;
239
    } else if (IN6_IS_ADDR_V4MAPPED(addr) &&
240
	       ((struct in6_addr*)addr)->s6_addr[12] == 127) {
241
      /* IPv4 mapped loopback address */
242
      ret = 1;
243
    }
244
  } else {
245
    return 0;
246
  }
247
  gairet = getnameinfo((struct sockaddr*)&s, sizeof(struct sockaddr_storage),
248
		       host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
249
  if (gairet != 0) {
250
    ErrorF(" => %s\n", gai_strerror(gairet));
251
  } else {
252
    ErrorF("is_loopback(%s) = %d\n", host, ret);
253
  }
254
  return ret;
255
}
256
212
static void
257
static void
213
XdmcpRegisterManufacturerDisplayID (char *name, int length)
258
XdmcpRegisterManufacturerDisplayID (char *name, int length)
214
{
259
{
Lines 438-445 Link Here
438
 * Register the host address for the display
483
 * Register the host address for the display
439
 */
484
 */
440
485
441
static ARRAY16		ConnectionTypes;
486
static ARRAY16		ConnectionTypes[2];
442
static ARRAYofARRAY8	ConnectionAddresses;
487
static ARRAYofARRAY8	ConnectionAddresses[2];
443
static long		xdmcpGeneration;
488
static long		xdmcpGeneration;
444
489
445
void
490
void
Lines 451-462 Link Here
451
    int	    i;
496
    int	    i;
452
    CARD8   *newAddress;
497
    CARD8   *newAddress;
453
498
499
    /*
500
     * Index for ConnectionTypes and ConnectionAddresses:
501
     * 1 for loopback address, 0 for remote addresses.
502
     */
503
    int     l;
504
454
    if (xdmcpGeneration != serverGeneration)
505
    if (xdmcpGeneration != serverGeneration)
455
    {
506
    {
456
	XdmcpDisposeARRAY16 (&ConnectionTypes);
507
	XdmcpDisposeARRAY16 (&ConnectionTypes[0]);
457
	XdmcpDisposeARRAYofARRAY8 (&ConnectionAddresses);
508
	XdmcpDisposeARRAY16 (&ConnectionTypes[1]);
509
	XdmcpDisposeARRAYofARRAY8 (&ConnectionAddresses[0]);
510
	XdmcpDisposeARRAYofARRAY8 (&ConnectionAddresses[1]);
458
	xdmcpGeneration = serverGeneration;
511
	xdmcpGeneration = serverGeneration;
459
    }
512
    }
513
    l = is_loopback(type, address);
460
    if (xdm_from != NULL) {	/* Only register the requested address */
514
    if (xdm_from != NULL) {	/* Only register the requested address */
461
	const void *regAddr = address;
515
	const void *regAddr = address;
462
	const void *fromAddr = NULL;
516
	const void *fromAddr = NULL;
Lines 490-516 Link Here
490
	    return;
544
	    return;
491
	}
545
	}
492
    }
546
    }
493
    if (ConnectionAddresses.length + 1 == 256)
547
    if (ConnectionAddresses[l].length + 1 == 256)
494
	return;
548
	return;
495
    newAddress = xalloc (addrlen * sizeof (CARD8));
549
    newAddress = xalloc (addrlen * sizeof (CARD8));
496
    if (!newAddress)
550
    if (!newAddress)
497
	return;
551
	return;
498
    if (!XdmcpReallocARRAY16 (&ConnectionTypes, ConnectionTypes.length + 1))
552
    if (!XdmcpReallocARRAY16 (&ConnectionTypes[l], ConnectionTypes[l].length + 1))
499
    {
553
    {
500
	xfree (newAddress);
554
	xfree (newAddress);
501
	return;
555
	return;
502
    }
556
    }
503
    if (!XdmcpReallocARRAYofARRAY8 (&ConnectionAddresses,
557
    if (!XdmcpReallocARRAYofARRAY8 (&ConnectionAddresses[l],
504
				    ConnectionAddresses.length +  1))
558
				    ConnectionAddresses[l].length +  1))
505
    {
559
    {
506
	xfree (newAddress);
560
	xfree (newAddress);
507
	return;
561
	return;
508
    }
562
    }
509
    ConnectionTypes.data[ConnectionTypes.length - 1] = (CARD16) type;
563
    ConnectionTypes[l].data[ConnectionTypes[l].length - 1] = (CARD16) type;
510
    for (i = 0; i < addrlen; i++)
564
    for (i = 0; i < addrlen; i++)
511
	newAddress[i] = address[i];
565
	newAddress[i] = address[i];
512
    ConnectionAddresses.data[ConnectionAddresses.length-1].data = newAddress;
566
    ConnectionAddresses[l].data[ConnectionAddresses[l].length-1].data = newAddress;
513
    ConnectionAddresses.data[ConnectionAddresses.length-1].length = addrlen;
567
    ConnectionAddresses[l].data[ConnectionAddresses[l].length-1].length = addrlen;
514
}
568
}
515
569
516
/*
570
/*
Lines 1176-1187 Link Here
1176
    CARD16	    XdmcpConnectionType;
1230
    CARD16	    XdmcpConnectionType;
1177
    ARRAY8	    authenticationData;
1231
    ARRAY8	    authenticationData;
1178
    int		    socketfd = xdmcpSocket;
1232
    int		    socketfd = xdmcpSocket;
1233
    int             l;
1179
1234
1180
    switch (SOCKADDR_FAMILY(ManagerAddress))
1235
    switch (SOCKADDR_FAMILY(ManagerAddress))
1181
    {
1236
    {
1182
    case AF_INET:	XdmcpConnectionType=FamilyInternet; break;
1237
    case AF_INET:
1238
      XdmcpConnectionType=FamilyInternet;
1239
      l = is_loopback(XdmcpConnectionType, &(((struct sockaddr_in*)&ManagerAddress)->sin_addr.s_addr));
1240
      break;
1183
#if defined(IPv6) && defined(AF_INET6)
1241
#if defined(IPv6) && defined(AF_INET6)
1184
    case AF_INET6:	XdmcpConnectionType=FamilyInternet6; break;
1242
    case AF_INET6:
1243
      XdmcpConnectionType=FamilyInternet6;
1244
      l = is_loopback(XdmcpConnectionType, ((struct sockaddr_in6*)&ManagerAddress)->sin6_addr.s6_addr);
1245
      break;
1185
#endif
1246
#endif
1186
    default:		XdmcpConnectionType=0xffff; break;
1247
    default:		XdmcpConnectionType=0xffff; break;
1187
    }
1248
    }
Lines 1190-1199 Link Here
1190
    header.opcode = (CARD16) REQUEST;
1251
    header.opcode = (CARD16) REQUEST;
1191
1252
1192
    length = 2;					    /* display number */
1253
    length = 2;					    /* display number */
1193
    length += 1 + 2 * ConnectionTypes.length;	    /* connection types */
1254
    length += 1 + 2 * ConnectionTypes[l].length;	    /* connection types */
1194
    length += 1;				    /* connection addresses */
1255
    length += 1;				    /* connection addresses */
1195
    for (i = 0; i < ConnectionAddresses.length; i++)
1256
    for (i = 0; i < ConnectionAddresses[l].length; i++)
1196
	length += 2 + ConnectionAddresses.data[i].length;
1257
	length += 2 + ConnectionAddresses[l].data[i].length;
1197
    authenticationData.length = 0;
1258
    authenticationData.length = 0;
1198
    authenticationData.data = 0;
1259
    authenticationData.data = 0;
1199
    if (AuthenticationFuncs)
1260
    if (AuthenticationFuncs)
Lines 1216-1242 Link Here
1216
	return;
1277
	return;
1217
    }
1278
    }
1218
    XdmcpWriteCARD16 (&buffer, DisplayNumber);
1279
    XdmcpWriteCARD16 (&buffer, DisplayNumber);
1219
    XdmcpWriteCARD8 (&buffer, ConnectionTypes.length);
1280
    XdmcpWriteCARD8 (&buffer, ConnectionTypes[l].length);
1220
1281
1221
    /* The connection array is send reordered, so that connections of	*/
1282
    /* The connection array is send reordered, so that connections of	*/
1222
    /* the same address type as the XDMCP manager connection are send	*/
1283
    /* the same address type as the XDMCP manager connection are send	*/
1223
    /* first. This works around a bug in xdm. mario@klebsch.de 		*/
1284
    /* first. This works around a bug in xdm. mario@klebsch.de 		*/
1224
    for (i = 0; i < (int)ConnectionTypes.length; i++)
1285
    for (i = 0; i < (int)ConnectionTypes[l].length; i++)
1225
	if (ConnectionTypes.data[i]==XdmcpConnectionType)
1286
	if (ConnectionTypes[l].data[i]==XdmcpConnectionType)
1226
	    XdmcpWriteCARD16 (&buffer, ConnectionTypes.data[i]);
1287
	    XdmcpWriteCARD16 (&buffer, ConnectionTypes[l].data[i]);
1227
    for (i = 0; i < (int)ConnectionTypes.length; i++)
1288
    for (i = 0; i < (int)ConnectionTypes[l].length; i++)
1228
	if (ConnectionTypes.data[i]!=XdmcpConnectionType)
1289
	if (ConnectionTypes[l].data[i]!=XdmcpConnectionType)
1229
	    XdmcpWriteCARD16 (&buffer, ConnectionTypes.data[i]);
1290
	    XdmcpWriteCARD16 (&buffer, ConnectionTypes[l].data[i]);
1230
1291
1231
    XdmcpWriteCARD8 (&buffer, ConnectionAddresses.length);
1292
    XdmcpWriteCARD8 (&buffer, ConnectionAddresses[l].length);
1232
    for (i = 0; i < (int)ConnectionAddresses.length; i++)
1293
    for (i = 0; i < (int)ConnectionAddresses[l].length; i++)
1233
	if ( (i<ConnectionTypes.length) && 
1294
	if ( (i<ConnectionTypes[l].length) && 
1234
	     (ConnectionTypes.data[i]==XdmcpConnectionType) )
1295
	     (ConnectionTypes[l].data[i]==XdmcpConnectionType) )
1235
	    XdmcpWriteARRAY8 (&buffer, &ConnectionAddresses.data[i]);
1296
	    XdmcpWriteARRAY8 (&buffer, &ConnectionAddresses[l].data[i]);
1236
    for (i = 0; i < (int)ConnectionAddresses.length; i++)
1297
    for (i = 0; i < (int)ConnectionAddresses[l].length; i++)
1237
	if ( (i>=ConnectionTypes.length) ||
1298
	if ( (i>=ConnectionTypes[l].length) ||
1238
	     (ConnectionTypes.data[i]!=XdmcpConnectionType) )
1299
	     (ConnectionTypes[l].data[i]!=XdmcpConnectionType) )
1239
	    XdmcpWriteARRAY8 (&buffer, &ConnectionAddresses.data[i]);
1300
	    XdmcpWriteARRAY8 (&buffer, &ConnectionAddresses[l].data[i]);
1240
1301
1241
    XdmcpWriteARRAY8 (&buffer, AuthenticationName);
1302
    XdmcpWriteARRAY8 (&buffer, AuthenticationName);
1242
    XdmcpWriteARRAY8 (&buffer, &authenticationData);
1303
    XdmcpWriteARRAY8 (&buffer, &authenticationData);

Return to bug 625593