aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/os
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/os')
-rw-r--r--xorg-server/os/WaitFor.c6
-rw-r--r--xorg-server/os/access.c127
-rw-r--r--xorg-server/os/auth.c12
-rw-r--r--xorg-server/os/connection.c59
-rw-r--r--xorg-server/os/io.c1
-rw-r--r--xorg-server/os/log.c16
-rw-r--r--xorg-server/os/makefile36
-rw-r--r--xorg-server/os/oscolor.c4
-rw-r--r--xorg-server/os/osinit.c5
-rw-r--r--xorg-server/os/utils.c98
-rw-r--r--xorg-server/os/xdmcp.c31
-rw-r--r--xorg-server/os/xprintf.c12
-rw-r--r--xorg-server/os/xstrans.c4
13 files changed, 317 insertions, 94 deletions
diff --git a/xorg-server/os/WaitFor.c b/xorg-server/os/WaitFor.c
index ac4b58e48..025f2a2a4 100644
--- a/xorg-server/os/WaitFor.c
+++ b/xorg-server/os/WaitFor.c
@@ -209,6 +209,12 @@ WaitForSomething(int *pClientsReady)
wt = &waittime;
}
}
+ if (!wt)
+ {
+ wt = &waittime;
+ waittime.tv_sec = 0;
+ waittime.tv_usec = 100;
+ }
XFD_COPYSET(&AllSockets, &LastSelectMask);
}
SmartScheduleStopTimer ();
diff --git a/xorg-server/os/access.c b/xorg-server/os/access.c
index 32692f836..11c1319d2 100644
--- a/xorg-server/os/access.c
+++ b/xorg-server/os/access.c
@@ -390,70 +390,81 @@ DefineSelf (int fd)
hp = _XGethostbyname(name.nodename, hparams);
if (hp != NULL)
{
- saddr.sa.sa_family = hp->h_addrtype;
- switch (hp->h_addrtype) {
- case AF_INET:
- inetaddr = (struct sockaddr_in *) (&(saddr.sa));
- acopy ( hp->h_addr, &(inetaddr->sin_addr), hp->h_length);
- len = sizeof(saddr.sa);
- break;
-#if defined(IPv6) && defined(AF_INET6)
- case AF_INET6:
- inet6addr = (struct sockaddr_in6 *) (&(saddr.sa));
- acopy ( hp->h_addr, &(inet6addr->sin6_addr), hp->h_length);
- len = sizeof(saddr.in6);
- break;
-#endif
- default:
- goto DefineLocalHost;
- }
- family = ConvertAddr ( &(saddr.sa), &len, (pointer *)&addr);
- if ( family != -1 && family != FamilyLocal )
+ #ifdef h_addr
+ #define hp_addr *list
+ char **list;
+
+ /* iterate over the addresses */
+ for (list = hp->h_addr_list; *list; list++)
+ #else
+ #define hp_addr hp->h_addr
+ #endif
{
- for (host = selfhosts;
- host && !addrEqual (family, addr, len, host);
- host = host->next) ;
- if (!host)
+ saddr.sa.sa_family = hp->h_addrtype;
+ switch (hp->h_addrtype) {
+ case AF_INET:
+ inetaddr = (struct sockaddr_in *) (&(saddr.sa));
+ acopy ( hp_addr, &(inetaddr->sin_addr), hp->h_length);
+ len = sizeof(saddr.sa);
+ break;
+#if defined(IPv6) && defined(AF_INET6)
+ case AF_INET6:
+ inet6addr = (struct sockaddr_in6 *) (&(saddr.sa));
+ acopy ( hp_addr, &(inet6addr->sin6_addr), hp->h_length);
+ len = sizeof(saddr.in6);
+ break;
+#endif
+ default:
+ goto DefineLocalHost;
+ }
+ family = ConvertAddr ( &(saddr.sa), &len, (pointer *)&addr);
+ if ( family != -1 && family != FamilyLocal )
{
- /* add this host to the host list. */
- MakeHost(host,len)
- if (host)
- {
- host->family = family;
- host->len = len;
- acopy ( addr, host->addr, len);
- host->next = selfhosts;
- selfhosts = host;
- }
-#ifdef XDMCP
- /*
- * If this is an Internet Address, but not the localhost
- * address (127.0.0.1), nor the bogus address (0.0.0.0),
- * register it.
- */
- if (family == FamilyInternet &&
- !(len == 4 &&
- ((addr[0] == 127) ||
- (addr[0] == 0 && addr[1] == 0 &&
- addr[2] == 0 && addr[3] == 0)))
- )
+ for (host = selfhosts;
+ host && !addrEqual (family, addr, len, host);
+ host = host->next) ;
+ if (!host)
{
- XdmcpRegisterConnection (family, (char *)addr, len);
- broad_addr = *inetaddr;
- ((struct sockaddr_in *) &broad_addr)->sin_addr.s_addr =
+ /* add this host to the host list. */
+ MakeHost(host,len)
+ if (host)
+ {
+ host->family = family;
+ host->len = len;
+ acopy ( addr, host->addr, len);
+ host->next = selfhosts;
+ selfhosts = host;
+ }
+ #ifdef XDMCP
+ /*
+ * If this is an Internet Address, but not the localhost
+ * address (127.0.0.1), nor the bogus address (0.0.0.0),
+ * register it.
+ */
+ if (family == FamilyInternet &&
+ !(len == 4 &&
+ ((addr[0] == 127) ||
+ (addr[0] == 0 && addr[1] == 0 &&
+ addr[2] == 0 && addr[3] == 0)))
+ )
+ {
+ XdmcpRegisterConnection (family, (char *)addr, len);
+ broad_addr = *inetaddr;
+ ((struct sockaddr_in *) &broad_addr)->sin_addr.s_addr =
htonl (INADDR_BROADCAST);
- XdmcpRegisterBroadcastAddress ((struct sockaddr_in *)
+ XdmcpRegisterBroadcastAddress ((struct sockaddr_in *)
&broad_addr);
+ }
+ #if defined(IPv6) && defined(AF_INET6)
+ else if (family == FamilyInternet6 &&
+ !(IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr)))
+ {
+ XdmcpRegisterConnection (family, (char *)addr, len);
+ }
+ #endif
+
+ #endif /* XDMCP */
}
-#if defined(IPv6) && defined(AF_INET6)
- else if (family == FamilyInternet6 &&
- !(IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr)))
- {
- XdmcpRegisterConnection (family, (char *)addr, len);
- }
-#endif
-
-#endif /* XDMCP */
}
}
}
diff --git a/xorg-server/os/auth.c b/xorg-server/os/auth.c
index 52868f0ba..f80e53155 100644
--- a/xorg-server/os/auth.c
+++ b/xorg-server/os/auth.c
@@ -318,11 +318,23 @@ GenerateAuthorization(
void
GenerateRandomData (int len, char *buf)
{
+#ifdef _MSC_VER
+ static HANDLE hAdvApi32;
+ static BOOLEAN (_stdcall * RtlGenRandom)(void *,unsigned long);
+
+ if (!hAdvApi32)
+ {
+ hAdvApi32=LoadLibrary("advapi32.dll");
+ RtlGenRandom=(BOOLEAN (_stdcall *)(void*,unsigned long))GetProcAddress(hAdvApi32,"SystemFunction036");
+ }
+ RtlGenRandom(buf, len);
+#else
int fd;
fd = open("/dev/urandom", O_RDONLY);
read(fd, buf, len);
close(fd);
+#endif
}
#endif /* XCSECURITY */
diff --git a/xorg-server/os/connection.c b/xorg-server/os/connection.c
index 8026423f7..eb9969369 100644
--- a/xorg-server/os/connection.c
+++ b/xorg-server/os/connection.c
@@ -67,6 +67,9 @@ SOFTWARE.
#ifdef WIN32
#include <X11/Xwinsock.h>
+#ifdef _DEBUG
+#define DEBUG
+#endif
#endif
#include <X11/X.h>
#include <X11/Xproto.h>
@@ -111,6 +114,10 @@ SOFTWARE.
#include "dixstruct.h"
#include "xace.h"
+#ifdef _MSC_VER
+typedef int pid_t;
+#endif
+
#define Pid_t pid_t
@@ -269,6 +276,23 @@ lookup_trans_conn (int fd)
return NULL;
}
+int
+TransIsListening(char *protocol)
+{
+ /* look for this transport in the list of listeners */
+ int i;
+ for (i = 0; i < ListenTransCount; i++)
+ {
+ if (!strcmp(protocol, ListenTransConns[i]->transptr->TransName))
+ {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+
/* Set MaxClients and lastfdesc, and allocate ConnectionTranslation */
void
@@ -975,7 +999,8 @@ CheckConnections(void)
struct timeval notime;
int r;
#ifdef WIN32
- fd_set savedAllClients;
+ fd_set savedAllSockets;
+ unsigned j;
#endif
notime.tv_sec = 0;
@@ -1001,19 +1026,23 @@ CheckConnections(void)
}
}
#else
- XFD_COPYSET(&AllClients, &savedAllClients);
- for (i = 0; i < XFD_SETCOUNT(&savedAllClients); i++)
+ XFD_COPYSET(&AllSockets, &savedAllSockets);
+ for (j=0; j<2; j++)
{
- curclient = XFD_FD(&savedAllClients, i);
- FD_ZERO(&tmask);
- FD_SET(curclient, &tmask);
- do {
- r = Select (curclient + 1, &tmask, NULL, NULL, &notime);
- } while (r < 0 && (errno == EINTR || errno == EAGAIN));
- if (r < 0)
- if (GetConnectionTranslation(curclient) > 0)
- CloseDownClient(clients[GetConnectionTranslation(curclient)]);
- }
+ for (i = 0; i < XFD_SETCOUNT(&savedAllSockets); i++)
+ {
+ curclient = XFD_FD(&savedAllSockets, i);
+ FD_ZERO(&tmask);
+ FD_SET(curclient, &tmask);
+ do {
+ r = Select (curclient + 1, &tmask, NULL, NULL, &notime);
+ } while (r < 0 && (WSAGetLastError() == WSAEINTR || WSAGetLastError() == WSAEWOULDBLOCK));
+ if (r < 0)
+ if (GetConnectionTranslation(curclient) > 0)
+ CloseDownClient(clients[GetConnectionTranslation(curclient)]);
+ }
+ XFD_COPYSET(&AllClients, &savedAllSockets);
+ }
#endif
}
@@ -1031,6 +1060,10 @@ CloseDownConnection(ClientPtr client)
if (FlushCallback)
CallCallbacks(&FlushCallback, NULL);
+#ifdef DEBUG
+ ErrorF("CloseDownConnection: client index = %d, socket fd = %d\n",
+ client->index, oc->fd);
+#endif
if (oc->output && oc->output->count)
FlushClient(client, oc, (char *)NULL, 0);
#ifdef XDMCP
diff --git a/xorg-server/os/io.c b/xorg-server/os/io.c
index dc83d3a34..21d2cf75c 100644
--- a/xorg-server/os/io.c
+++ b/xorg-server/os/io.c
@@ -939,6 +939,7 @@ FlushClient(ClientPtr who, OsCommPtr oc, const void *__extraBuf, int extraCount)
/* If we've arrived here, then the client is stuffed to the gills
and not ready to accept more. Make a note of it and buffer
the rest. */
+ errno=0;
FD_SET(connection, &ClientsWriteBlocked);
AnyClientsWriteBlocked = TRUE;
diff --git a/xorg-server/os/log.c b/xorg-server/os/log.c
index ee4b45fa4..0d45b7791 100644
--- a/xorg-server/os/log.c
+++ b/xorg-server/os/log.c
@@ -95,8 +95,14 @@ OR PERFORMANCE OF THIS SOFTWARE.
#ifdef WIN32
#include <process.h>
+#ifndef _MSC_VER
#define getpid(x) _getpid(x)
#endif
+#endif
+
+#ifdef _MSC_VER
+#define S_ISREG(m) (((m)&_S_IFMT) == _S_IFREG)
+#endif
#ifdef XF86BIGFONT
#include "xf86bigfontsrv.h"
@@ -268,7 +274,7 @@ LogSetParameter(LogParameter param, int value)
void
LogVWrite(int verb, const char *f, va_list args)
{
- static char tmpBuffer[1024];
+ char tmpBuffer[1024];
int len = 0;
static Bool newline = TRUE;
@@ -285,7 +291,8 @@ LogVWrite(int verb, const char *f, va_list args)
* stream(s).
*/
if (verb < 0 || logFileVerbosity >= verb || logVerbosity >= verb) {
- vsnprintf(tmpBuffer, sizeof(tmpBuffer), f, args);
+ vsnprintf(tmpBuffer, sizeof(tmpBuffer)-1, f, args);
+ tmpBuffer[sizeof(tmpBuffer)-1]=0;
len = strlen(tmpBuffer);
}
newline = (tmpBuffer[len-1] == '\n');
@@ -527,6 +534,8 @@ VAuditF(const char *f, va_list args)
free(prefix);
}
+extern char g_FatalErrorMessage[1024];
+
void
FatalError(const char *f, ...)
{
@@ -542,6 +551,9 @@ FatalError(const char *f, ...)
#ifdef __APPLE__
(void)vsnprintf(__crashreporter_info_buff__, sizeof(__crashreporter_info_buff__), f, args);
#endif
+#ifdef WIN32
+ vsnprintf(g_FatalErrorMessage, 1024, f, args);
+#endif
VErrorF(f, args);
va_end(args);
ErrorF("\n");
diff --git a/xorg-server/os/makefile b/xorg-server/os/makefile
new file mode 100644
index 000000000..e7a286970
--- /dev/null
+++ b/xorg-server/os/makefile
@@ -0,0 +1,36 @@
+ifeq ($(DEBUG),1)
+DEFINES += XSERVER_DTRACE
+endif
+
+SECURERPC_SRCS = rpcauth.c
+XDMCP_SRCS = xdmcp.c
+STRLCAT_SRCS = strlcat.c strlcpy.c
+XORG_SRCS = log.c
+
+CSRCS = \
+ WaitFor.c \
+ access.c \
+ auth.c \
+ backtrace.c \
+ connection.c \
+ io.c \
+ mitauth.c \
+ oscolor.c \
+ osinit.c \
+ utils.c \
+ strcasecmp.c \
+ strcasestr.c \
+ xdmauth.c \
+ xsha1.c \
+ xstrans.c \
+ xprintf.c \
+ $(XORG_SRCS)
+
+CSRCS += $(SECURERPC_SRCS)
+
+CSRCS += $(XDMCP_SRCS)
+
+CSRCS += $(STRLCAT_SRCS)
+
+LIBRARY=libos
+
diff --git a/xorg-server/os/oscolor.c b/xorg-server/os/oscolor.c
index 7f6b93880..4e1513f53 100644
--- a/xorg-server/os/oscolor.c
+++ b/xorg-server/os/oscolor.c
@@ -49,6 +49,10 @@ SOFTWARE.
#include <dix-config.h>
#endif
+#ifdef _MSC_VER
+#define strncasecmp _strnicmp
+#endif
+
#include <X11/keysym.h>
#include "os.h"
diff --git a/xorg-server/os/osinit.c b/xorg-server/os/osinit.c
index 57cd2c511..6ecf0821c 100644
--- a/xorg-server/os/osinit.c
+++ b/xorg-server/os/osinit.c
@@ -165,6 +165,7 @@ OsInit(void)
char fname[PATH_MAX];
if (!been_here) {
+#ifndef _MSC_VER
struct sigaction act, oact;
int i;
int siglist[] = { SIGSEGV, SIGQUIT, SIGILL, SIGFPE, SIGBUS,
@@ -208,7 +209,7 @@ OsInit(void)
int failure_signal = SIGQUIT;
dlinfo(RTLD_SELF, RTLD_DI_SETSIGNAL, &failure_signal);
#endif
-
+#endif
#if !defined(__SCO__) && !defined(__CYGWIN__) && !defined(__UNIXWARE__)
fclose(stdin);
fclose(stdout);
@@ -247,8 +248,10 @@ OsInit(void)
#endif
}
+#ifndef _MSC_VER
if (getpgrp () == 0)
setpgid (0, 0);
+#endif
#ifdef RLIMIT_DATA
if (limitDataSpace >= 0)
diff --git a/xorg-server/os/utils.c b/xorg-server/os/utils.c
index 179a4b089..11d2ac8fa 100644
--- a/xorg-server/os/utils.c
+++ b/xorg-server/os/utils.c
@@ -201,6 +201,11 @@ Bool PanoramiXExtensionDisabledHack = FALSE;
int auditTrailLevel = 1;
+#ifdef _MSC_VER
+static HANDLE s_hSmartScheduleTimer = NULL;
+static HANDLE s_hSmartScheduleTimerQueue = NULL;
+#endif
+
#if defined(SVR4) || defined(__linux__) || defined(CSRG_BASED)
#define HAS_SAVED_IDS_AND_SETEUID
#endif
@@ -208,6 +213,9 @@ int auditTrailLevel = 1;
OsSigHandlerPtr
OsSignal(int sig, OsSigHandlerPtr handler)
{
+#ifdef X_NOT_POSIX
+ return signal(sig, handler);
+#else
struct sigaction act, oact;
sigemptyset(&act.sa_mask);
@@ -218,6 +226,7 @@ OsSignal(int sig, OsSigHandlerPtr handler)
if (sigaction(sig, &act, &oact))
perror("sigaction");
return oact.sa_handler;
+#endif
}
/*
@@ -243,7 +252,7 @@ OsSignal(int sig, OsSigHandlerPtr handler)
#endif
static Bool StillLocking = FALSE;
-static char LockFile[PATH_MAX];
+static char szLockFile[PATH_MAX];
static Bool nolock = FALSE;
/*
@@ -255,26 +264,34 @@ static Bool nolock = FALSE;
void
LockServer(void)
{
+#if defined(WIN32) && !defined(__CYGWIN__)
+ char MutexName[100];
+ sprintf(MutexName, "Global\\VcXsrv_Mutex_%d\n", getpid());
+ if (!CreateMutex(NULL,TRUE,MutexName) || GetLastError()== ERROR_ALREADY_EXISTS)
+ {
+ FatalError("Server is already active for display %d\n", atoi(display));
+ }
+#else
+ char port[20];
char tmp[PATH_MAX], pid_str[12];
int lfd, i, haslock, l_pid, t;
char *tmppath = NULL;
int len;
- char port[20];
if (nolock) return;
/*
* Path names
*/
tmppath = LOCK_DIR;
-
sprintf(port, "%d", atoi(display));
+
len = strlen(LOCK_PREFIX) > strlen(LOCK_TMP_PREFIX) ? strlen(LOCK_PREFIX) :
strlen(LOCK_TMP_PREFIX);
len += strlen(tmppath) + strlen(port) + strlen(LOCK_SUFFIX) + 1;
- if (len > sizeof(LockFile))
+ if (len > sizeof(szLockFile))
FatalError("Display name `%s' is too long\n", port);
(void)sprintf(tmp, "%s" LOCK_TMP_PREFIX "%s" LOCK_SUFFIX, tmppath, port);
- (void)sprintf(LockFile, "%s" LOCK_PREFIX "%s" LOCK_SUFFIX, tmppath, port);
+ (void)sprintf(szLockFile, "%s" LOCK_PREFIX "%s" LOCK_SUFFIX, tmppath, port);
/*
* Create a temporary file containing our PID. Attempt three times
@@ -316,7 +333,7 @@ LockServer(void)
i = 0;
haslock = 0;
while ((!haslock) && (i++ < 3)) {
- haslock = (link(tmp,LockFile) == 0);
+ haslock = (link(tmp,szLockFile) == 0);
if (haslock) {
/*
* We're done.
@@ -327,17 +344,17 @@ LockServer(void)
/*
* Read the pid from the existing file
*/
- lfd = open(LockFile, O_RDONLY);
+ lfd = open(szLockFile, O_RDONLY);
if (lfd < 0) {
unlink(tmp);
- FatalError("Can't read lock file %s\n", LockFile);
+ FatalError("Can't read lock file %s\n", szLockFile);
}
pid_str[0] = '\0';
if (read(lfd, pid_str, 11) != 11) {
/*
* Bogus lock file.
*/
- unlink(LockFile);
+ unlink(szLockFile);
close(lfd);
continue;
}
@@ -354,7 +371,7 @@ LockServer(void)
/*
* Stale lock file.
*/
- unlink(LockFile);
+ unlink(szLockFile);
continue;
}
else if (((t < 0) && (errno == EPERM)) || (t == 0)) {
@@ -364,14 +381,15 @@ LockServer(void)
unlink(tmp);
FatalError("Server is already active for display %s\n%s %s\n%s\n",
port, "\tIf this server is no longer running, remove",
- LockFile, "\tand start again.");
+ szLockFile, "\tand start again.");
}
}
}
unlink(tmp);
if (!haslock)
- FatalError("Could not create server lock file: %s\n", LockFile);
+ FatalError("Could not create server lock file: %s\n", szLockFile);
StillLocking = FALSE;
+#endif
}
/*
@@ -385,7 +403,7 @@ UnlockServer(void)
if (!StillLocking){
- (void) unlink(LockFile);
+ (void) unlink(szLockFile);
}
}
@@ -1124,6 +1142,12 @@ XNFstrdup(const char *s)
void
SmartScheduleStopTimer (void)
{
+#ifdef _MSC_VER
+ if (SmartScheduleDisable)
+ return;
+ DeleteTimerQueueTimer(s_hSmartScheduleTimerQueue, s_hSmartScheduleTimer, NULL);
+ s_hSmartScheduleTimer=NULL;
+#else
struct itimerval timer;
if (SmartScheduleDisable)
@@ -1133,11 +1157,36 @@ SmartScheduleStopTimer (void)
timer.it_value.tv_sec = 0;
timer.it_value.tv_usec = 0;
(void) setitimer (ITIMER_REAL, &timer, 0);
+#endif
+}
+
+#ifdef _MSC_VER
+static VOID CALLBACK SmartScheduleTimer( PVOID lpParameter, BOOLEAN TimerOrWaitFired)
+#else
+static void SmartScheduleTimer (int sig)
+#endif
+{
+ SmartScheduleTime += SmartScheduleInterval;
}
+
void
SmartScheduleStartTimer (void)
{
+#ifdef _MSC_VER
+ if (SmartScheduleDisable)
+ return;
+
+ if (!CreateTimerQueueTimer( &s_hSmartScheduleTimer, s_hSmartScheduleTimerQueue, SmartScheduleTimer, NULL
+ , SmartScheduleInterval, SmartScheduleInterval, WT_EXECUTEONLYONCE|WT_EXECUTEINPERSISTENTTHREAD))
+ {
+ DWORD Error=GetLastError();
+ ErrorF("Error starting timer, smart scheduling disabled: 0x%x (%d)\n",Error,Error);
+ CloseHandle(s_hSmartScheduleTimer);
+ SmartScheduleDisable = TRUE;
+ return;
+ }
+#else
struct itimerval timer;
if (SmartScheduleDisable)
@@ -1147,17 +1196,23 @@ SmartScheduleStartTimer (void)
timer.it_value.tv_sec = 0;
timer.it_value.tv_usec = SmartScheduleInterval * 1000;
setitimer (ITIMER_REAL, &timer, 0);
-}
-
-static void
-SmartScheduleTimer (int sig)
-{
- SmartScheduleTime += SmartScheduleInterval;
+#endif
}
void
SmartScheduleInit (void)
{
+#ifdef _MSC_VER
+ if (SmartScheduleDisable)
+ return;
+ s_hSmartScheduleTimerQueue = CreateTimerQueue();
+ if (!s_hSmartScheduleTimerQueue)
+ {
+ DWORD Error=GetLastError();
+ ErrorF("Error creating timer, smart scheduling disabled: 0x%x (%d)\n",Error,Error);
+ SmartScheduleDisable = TRUE;
+ }
+#else
struct sigaction act;
if (SmartScheduleDisable)
@@ -1174,6 +1229,7 @@ SmartScheduleInit (void)
perror ("sigaction for smart scheduler");
SmartScheduleDisable = TRUE;
}
+#endif
}
#ifdef SIG_BLOCK
@@ -1535,6 +1591,7 @@ Fclose(pointer iop)
*/
/* Consider LD* variables insecure? */
+#ifndef _MSC_VER
#ifndef REMOVE_ENV_LD
#define REMOVE_ENV_LD 1
#endif
@@ -1543,6 +1600,7 @@ Fclose(pointer iop)
#ifndef REMOVE_LONG_ENV
#define REMOVE_LONG_ENV 1
#endif
+#endif
/*
* Disallow stdout or stderr as pipes? It's possible to block the X server
@@ -1573,7 +1631,7 @@ Fclose(pointer iop)
#endif
#define MAX_ARG_LENGTH 128
-#define MAX_ENV_LENGTH 256
+#define MAX_ENV_LENGTH 2048
#define MAX_ENV_PATH_LENGTH 2048 /* Limit for *PATH and TERMCAP */
#if USE_ISPRINT
diff --git a/xorg-server/os/xdmcp.c b/xorg-server/os/xdmcp.c
index 3a6a3bb7d..6429b8b77 100644
--- a/xorg-server/os/xdmcp.c
+++ b/xorg-server/os/xdmcp.c
@@ -203,6 +203,11 @@ static void XdmcpWakeupHandler(
int /*i*/,
pointer /*LastSelectMask*/);
+#define XSERV_t
+#define TRANS_SERVER
+#define TRANS_REOPEN
+#include <X11/Xtrans/Xtrans.h>
+
/*
* Register the Manufacturer display ID
*/
@@ -587,6 +592,32 @@ XdmcpInit(void)
(pointer) 0);
timeOutRtx = 0;
DisplayNumber = (CARD16) atoi(display);
+ if (ConnectionTypes.length>1 && xdm_from==NULL)
+ {
+ unsigned i=0;
+ char ErrorMessage[1024];
+ sprintf(ErrorMessage,"Multiple ip-addresses detected:\n");
+ for (i=0; i<ConnectionTypes.length; i++)
+ {
+ int AddrLen=ConnectionAddresses.data[i].length;
+ if (AddrLen==4)
+ sprintf(ErrorMessage+strlen(ErrorMessage)," %d.%d.%d.%d\n",
+ ConnectionAddresses.data[i].data[0],
+ ConnectionAddresses.data[i].data[1],
+ ConnectionAddresses.data[i].data[2],
+ ConnectionAddresses.data[i].data[3]);
+ else
+ {
+ int j;
+ sprintf(ErrorMessage+strlen(ErrorMessage)," ");
+ for (j=0; j<AddrLen; j++)
+ sprintf(ErrorMessage+strlen(ErrorMessage),"%02x",ConnectionAddresses.data[i].data[j]);
+ sprintf(ErrorMessage+strlen(ErrorMessage),"\n");
+ }
+ }
+ sprintf(ErrorMessage+strlen(ErrorMessage),"Please specify the ip-address you want to use with -from\n");
+ FatalError(ErrorMessage);
+ }
get_xdmcp_sock();
send_packet();
}
diff --git a/xorg-server/os/xprintf.c b/xorg-server/os/xprintf.c
index 5a42df2d1..cdd276a3d 100644
--- a/xorg-server/os/xprintf.c
+++ b/xorg-server/os/xprintf.c
@@ -39,7 +39,9 @@
# ifdef __va_copy
# define va_copy __va_copy
# else
+# ifndef _MSC_VER
# error "no working va_copy was found"
+# endif
# endif
#endif
@@ -48,11 +50,16 @@ Xvprintf(const char *format, va_list va)
{
char *ret;
int size;
+
+#ifdef _MSC_VER
+ size = vsnprintf(NULL, 0, format, va);
+#else
va_list va2;
va_copy(va2, va);
size = vsnprintf(NULL, 0, format, va2);
va_end(va2);
+#endif
ret = (char *)malloc(size + 1);
if (ret == NULL)
@@ -78,11 +85,16 @@ XNFvprintf(const char *format, va_list va)
{
char *ret;
int size;
+
+#ifdef _MSC_VER
+ size = vsnprintf(NULL, 0, format, va);
+#else
va_list va2;
va_copy(va2, va);
size = vsnprintf(NULL, 0, format, va2);
va_end(va2);
+#endif
ret = (char *)xnfalloc(size + 1);
if (ret == NULL)
diff --git a/xorg-server/os/xstrans.c b/xorg-server/os/xstrans.c
index c086e225b..dd75ab53e 100644
--- a/xorg-server/os/xstrans.c
+++ b/xorg-server/os/xstrans.c
@@ -5,4 +5,8 @@
#define TRANS_REOPEN
#define TRANS_SERVER
#define XSERV_t
+#ifndef TCPCONN
+#define TCPCONN
+#endif
+
#include <X11/Xtrans/transport.c>