From bd433c6487a52f95e6bb949d5698dc5ea0923713 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Mon, 10 Oct 2011 17:47:40 +0200 Subject: Imported nx-X11-3.3.0-6.tar.gz Summary: Imported nx-X11-3.3.0-6.tar.gz Keywords: Imported nx-X11-3.3.0-6.tar.gz into Git repository --- nx-X11/CHANGELOG | 8 ++ nx-X11/CHANGELOG.NX.original | 8 ++ nx-X11/lib/X11/XlibInt.c | 61 +++++++- nx-X11/lib/X11/XlibInt.c.NX.original | 61 +++++++- nx-X11/programs/Xserver/os/xprintf.c | 59 ++++++++ nx-X11/programs/Xserver/os/xprintf.c.NX.original | 163 ++++++++++++++++++++++ nx-X11/programs/Xserver/os/xprintf.c.X.original | 104 ++++++++++++++ nx-X11/programs/Xserver/xkb/ddxLoad.c | 7 +- nx-X11/programs/Xserver/xkb/ddxLoad.c.NX.original | 7 +- 9 files changed, 474 insertions(+), 4 deletions(-) create mode 100644 nx-X11/programs/Xserver/os/xprintf.c.NX.original create mode 100644 nx-X11/programs/Xserver/os/xprintf.c.X.original diff --git a/nx-X11/CHANGELOG b/nx-X11/CHANGELOG index a6c169dd7..7b410fd55 100644 --- a/nx-X11/CHANGELOG +++ b/nx-X11/CHANGELOG @@ -1,5 +1,13 @@ ChangeLog: +nx-X11-3.3.0-6 + +- Fixed TR03G02198. Reimplemented Xvprintf() in Xserver/os to handle + the case in which vsnprintf returned -1. + +- Returning from _XSeqSyncFunction() and _XReply() if an I/O error is + detected. + nx-X11-3.3.0-5 - Fixed TR01G02163. Signals need to be blocked before the call to diff --git a/nx-X11/CHANGELOG.NX.original b/nx-X11/CHANGELOG.NX.original index a6c169dd7..7b410fd55 100644 --- a/nx-X11/CHANGELOG.NX.original +++ b/nx-X11/CHANGELOG.NX.original @@ -1,5 +1,13 @@ ChangeLog: +nx-X11-3.3.0-6 + +- Fixed TR03G02198. Reimplemented Xvprintf() in Xserver/os to handle + the case in which vsnprintf returned -1. + +- Returning from _XSeqSyncFunction() and _XReply() if an I/O error is + detected. + nx-X11-3.3.0-5 - Fixed TR01G02163. Signals need to be blocked before the call to diff --git a/nx-X11/lib/X11/XlibInt.c b/nx-X11/lib/X11/XlibInt.c index 97758e7ab..6dcd1f0f6 100644 --- a/nx-X11/lib/X11/XlibInt.c +++ b/nx-X11/lib/X11/XlibInt.c @@ -877,6 +877,19 @@ int _XSeqSyncFunction( xGetInputFocusReply rep; register xReq *req; +#ifdef NX_TRANS_SOCKET +#ifdef NX_TRANS_DEBUG + fprintf(stderr, "_XSeqSyncFunction: Going to synchronize the display.\n"); +#endif + if (dpy->flags & XlibDisplayIOError) + { +#ifdef NX_TRANS_DEBUG + fprintf(stderr, "_XSeqSyncFunction: Returning 0 with I/O error detected.\n"); +#endif + return 0; + } +#endif + LockDisplay(dpy); if ((dpy->request - dpy->last_request_read) >= (BUFSIZE / SIZEOF(xReq))) { GetEmptyReq(GetInputFocus, req); @@ -930,6 +943,10 @@ static void _XFlushInt( int congestion; #endif +#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) + fprintf(stderr, "_XFlushInt: Entering flush with [%d] bytes to write.\n", + (dpy->bufptr - dpy->buffer)); +#endif /* This fix resets the bufptr to the front of the buffer so * additional appends to the bufptr will not corrupt memory. Since * the server is down, these appends are no-op's anyway but @@ -937,6 +954,9 @@ static void _XFlushInt( */ if (dpy->flags & XlibDisplayIOError) { +#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) + fprintf(stderr, "_XFlushInt: Returning with I/O error detected.\n"); +#endif dpy->bufptr = dpy->buffer; dpy->last_req = (char *)&_dummy_request; return; @@ -1404,6 +1424,15 @@ void _XReadEvents( dpy->flags |= XlibDisplayReadEvents; i = _XRead (dpy, read_buf, (long) len); dpy->flags &= ~XlibDisplayReadEvents; +#ifdef NX_TRANS_SOCKET + if (dpy->flags & XlibDisplayIOError) + { +#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) + fprintf(stderr, "_XReadEvents: Returning with I/O error detected.\n"); +#endif + return; + } +#endif if (i == -2) { /* special flag from _XRead to say that internal connection has done XPutBackEvent. Which we can use so we're done. */ @@ -1841,10 +1870,17 @@ _XSend ( #endif #ifdef NX_TRANS_SOCKET +#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) + fprintf(stderr, "_XSend: Sending data with [%d] bytes to write.\n", + (dpy->bufptr - dpy->buffer)); +#endif if (!size || (dpy->flags & XlibDisplayIOError)) { if (dpy->flags & XlibDisplayIOError) { +#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) + fprintf(stderr, "_XSend: Returning with I/O error detected.\n"); +#endif dpy->bufptr = dpy->buffer; dpy->last_req = (char *)&_dummy_request; } @@ -2222,8 +2258,18 @@ _XReply ( fprintf(stderr, "_XReply: Going to wait for an X reply.\n"); #endif +#ifdef NX_TRANS_SOCKET + if (dpy->flags & XlibDisplayIOError) + { +#ifdef NX_TRANS_DEBUG + fprintf(stderr, "_XReply: Returning 0 with I/O error detected.\n"); +#endif + return 0; + } +#else if (dpy->flags & XlibDisplayIOError) return 0; +#endif #ifdef XTHREADS /* create our condition variable and append to list */ @@ -2239,6 +2285,9 @@ _XReply ( XThread_Self(), cvl); #endif +#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) + fprintf(stderr, "_XReply: Going to flush the display buffer.\n"); +#endif _XFlushInt(dpy, cvl ? cvl->cv : NULL); /* if it is not our turn to read a reply off the wire, * wait til we're at head of list. if there is an event waiter, @@ -3583,11 +3632,21 @@ _XIOError ( */ #ifdef NX_TRANS_TEST - fprintf(stderr, "_XIOError: Resetting the display buffers.\n"); + fprintf(stderr, "_XIOError: Resetting the display buffer.\n"); #endif dpy->bufptr = dpy->buffer; dpy->last_req = (char *) &_dummy_request; + +#ifdef NX_TRANS_TEST + fprintf(stderr, "_XIOError: Resetting the display flags.\n"); +#endif + + dpy->flags &= ~XlibDisplayProcConni; + dpy->flags &= ~XlibDisplayPrivSync; + dpy->flags &= ~XlibDisplayReadEvents; + dpy->flags &= ~XlibDisplayWriting; + dpy->flags &= ~XlibDisplayReply; #else exit (1); #endif diff --git a/nx-X11/lib/X11/XlibInt.c.NX.original b/nx-X11/lib/X11/XlibInt.c.NX.original index 97758e7ab..6dcd1f0f6 100644 --- a/nx-X11/lib/X11/XlibInt.c.NX.original +++ b/nx-X11/lib/X11/XlibInt.c.NX.original @@ -877,6 +877,19 @@ int _XSeqSyncFunction( xGetInputFocusReply rep; register xReq *req; +#ifdef NX_TRANS_SOCKET +#ifdef NX_TRANS_DEBUG + fprintf(stderr, "_XSeqSyncFunction: Going to synchronize the display.\n"); +#endif + if (dpy->flags & XlibDisplayIOError) + { +#ifdef NX_TRANS_DEBUG + fprintf(stderr, "_XSeqSyncFunction: Returning 0 with I/O error detected.\n"); +#endif + return 0; + } +#endif + LockDisplay(dpy); if ((dpy->request - dpy->last_request_read) >= (BUFSIZE / SIZEOF(xReq))) { GetEmptyReq(GetInputFocus, req); @@ -930,6 +943,10 @@ static void _XFlushInt( int congestion; #endif +#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) + fprintf(stderr, "_XFlushInt: Entering flush with [%d] bytes to write.\n", + (dpy->bufptr - dpy->buffer)); +#endif /* This fix resets the bufptr to the front of the buffer so * additional appends to the bufptr will not corrupt memory. Since * the server is down, these appends are no-op's anyway but @@ -937,6 +954,9 @@ static void _XFlushInt( */ if (dpy->flags & XlibDisplayIOError) { +#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) + fprintf(stderr, "_XFlushInt: Returning with I/O error detected.\n"); +#endif dpy->bufptr = dpy->buffer; dpy->last_req = (char *)&_dummy_request; return; @@ -1404,6 +1424,15 @@ void _XReadEvents( dpy->flags |= XlibDisplayReadEvents; i = _XRead (dpy, read_buf, (long) len); dpy->flags &= ~XlibDisplayReadEvents; +#ifdef NX_TRANS_SOCKET + if (dpy->flags & XlibDisplayIOError) + { +#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) + fprintf(stderr, "_XReadEvents: Returning with I/O error detected.\n"); +#endif + return; + } +#endif if (i == -2) { /* special flag from _XRead to say that internal connection has done XPutBackEvent. Which we can use so we're done. */ @@ -1841,10 +1870,17 @@ _XSend ( #endif #ifdef NX_TRANS_SOCKET +#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) + fprintf(stderr, "_XSend: Sending data with [%d] bytes to write.\n", + (dpy->bufptr - dpy->buffer)); +#endif if (!size || (dpy->flags & XlibDisplayIOError)) { if (dpy->flags & XlibDisplayIOError) { +#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) + fprintf(stderr, "_XSend: Returning with I/O error detected.\n"); +#endif dpy->bufptr = dpy->buffer; dpy->last_req = (char *)&_dummy_request; } @@ -2222,8 +2258,18 @@ _XReply ( fprintf(stderr, "_XReply: Going to wait for an X reply.\n"); #endif +#ifdef NX_TRANS_SOCKET + if (dpy->flags & XlibDisplayIOError) + { +#ifdef NX_TRANS_DEBUG + fprintf(stderr, "_XReply: Returning 0 with I/O error detected.\n"); +#endif + return 0; + } +#else if (dpy->flags & XlibDisplayIOError) return 0; +#endif #ifdef XTHREADS /* create our condition variable and append to list */ @@ -2239,6 +2285,9 @@ _XReply ( XThread_Self(), cvl); #endif +#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) + fprintf(stderr, "_XReply: Going to flush the display buffer.\n"); +#endif _XFlushInt(dpy, cvl ? cvl->cv : NULL); /* if it is not our turn to read a reply off the wire, * wait til we're at head of list. if there is an event waiter, @@ -3583,11 +3632,21 @@ _XIOError ( */ #ifdef NX_TRANS_TEST - fprintf(stderr, "_XIOError: Resetting the display buffers.\n"); + fprintf(stderr, "_XIOError: Resetting the display buffer.\n"); #endif dpy->bufptr = dpy->buffer; dpy->last_req = (char *) &_dummy_request; + +#ifdef NX_TRANS_TEST + fprintf(stderr, "_XIOError: Resetting the display flags.\n"); +#endif + + dpy->flags &= ~XlibDisplayProcConni; + dpy->flags &= ~XlibDisplayPrivSync; + dpy->flags &= ~XlibDisplayReadEvents; + dpy->flags &= ~XlibDisplayWriting; + dpy->flags &= ~XlibDisplayReply; #else exit (1); #endif diff --git a/nx-X11/programs/Xserver/os/xprintf.c b/nx-X11/programs/Xserver/os/xprintf.c index 07eaa1f58..a1ee21300 100644 --- a/nx-X11/programs/Xserver/os/xprintf.c +++ b/nx-X11/programs/Xserver/os/xprintf.c @@ -43,6 +43,63 @@ # endif #endif +#ifdef NXAGENT_SERVER + +#define PANIC +#define WARNING +#undef TEST +#undef DEBUG + +#define START_SIZE 256 +#define END_SIZE 2048 + +char * +Xvprintf(const char *format, va_list va) +{ + char *ret; + char *newret; + int size; + int r; + + size = 0; + + for (;;) + { + if (size == 0) + { + ret = (char *)malloc(START_SIZE); + if (ret == NULL) + return NULL; + size = START_SIZE; + } + else if (size < END_SIZE && + (newret = (char *) realloc(ret, 2 * size)) != NULL) + { + ret = newret; + size = 2 * size; + } + else + { + free(ret); + return NULL; + } + + r = vsnprintf(ret, size, format, va); + + if (r == -1 || r == size || r > size || r == size - 1) + { + continue; + } + else + { + ret[r] = 0; + return ret; + } + } +} + +#else + char * Xvprintf(const char *format, va_list va) { @@ -63,6 +120,8 @@ Xvprintf(const char *format, va_list va) return ret; } +#endif + char *Xprintf(const char *format, ...) { char *ret; diff --git a/nx-X11/programs/Xserver/os/xprintf.c.NX.original b/nx-X11/programs/Xserver/os/xprintf.c.NX.original new file mode 100644 index 000000000..a1ee21300 --- /dev/null +++ b/nx-X11/programs/Xserver/os/xprintf.c.NX.original @@ -0,0 +1,163 @@ +/* + * printf routines which xalloc their buffer + */ +/* + * Copyright (c) 2004 Alexander Gottwald + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name(s) of the above copyright + * holders shall not be used in advertising or otherwise to promote the sale, + * use or other dealings in this Software without prior written authorization. + */ +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include +#include "os.h" +#include +#include + +#ifndef va_copy +# ifdef __va_copy +# define va_copy __va_copy +# else +# error "no working va_copy was found" +# endif +#endif + +#ifdef NXAGENT_SERVER + +#define PANIC +#define WARNING +#undef TEST +#undef DEBUG + +#define START_SIZE 256 +#define END_SIZE 2048 + +char * +Xvprintf(const char *format, va_list va) +{ + char *ret; + char *newret; + int size; + int r; + + size = 0; + + for (;;) + { + if (size == 0) + { + ret = (char *)malloc(START_SIZE); + if (ret == NULL) + return NULL; + size = START_SIZE; + } + else if (size < END_SIZE && + (newret = (char *) realloc(ret, 2 * size)) != NULL) + { + ret = newret; + size = 2 * size; + } + else + { + free(ret); + return NULL; + } + + r = vsnprintf(ret, size, format, va); + + if (r == -1 || r == size || r > size || r == size - 1) + { + continue; + } + else + { + ret[r] = 0; + return ret; + } + } +} + +#else + +char * +Xvprintf(const char *format, va_list va) +{ + char *ret; + int size; + va_list va2; + + va_copy(va2, va); + size = vsnprintf(NULL, 0, format, va2); + va_end(va2); + + ret = (char *)Xalloc(size + 1); + if (ret == NULL) + return NULL; + + vsnprintf(ret, size + 1, format, va); + ret[size] = 0; + return ret; +} + +#endif + +char *Xprintf(const char *format, ...) +{ + char *ret; + va_list va; + va_start(va, format); + ret = Xvprintf(format, va); + va_end(va); + return ret; +} + +char * +XNFvprintf(const char *format, va_list va) +{ + char *ret; + int size; + va_list va2; + + va_copy(va2, va); + size = vsnprintf(NULL, 0, format, va2); + va_end(va2); + + ret = (char *)XNFalloc(size + 1); + if (ret == NULL) + return NULL; + + vsnprintf(ret, size + 1, format, va); + ret[size] = 0; + return ret; +} + +char *XNFprintf(const char *format, ...) +{ + char *ret; + va_list va; + va_start(va, format); + ret = XNFvprintf(format, va); + va_end(va); + return ret; +} diff --git a/nx-X11/programs/Xserver/os/xprintf.c.X.original b/nx-X11/programs/Xserver/os/xprintf.c.X.original new file mode 100644 index 000000000..07eaa1f58 --- /dev/null +++ b/nx-X11/programs/Xserver/os/xprintf.c.X.original @@ -0,0 +1,104 @@ +/* + * printf routines which xalloc their buffer + */ +/* + * Copyright (c) 2004 Alexander Gottwald + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name(s) of the above copyright + * holders shall not be used in advertising or otherwise to promote the sale, + * use or other dealings in this Software without prior written authorization. + */ +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include +#include "os.h" +#include +#include + +#ifndef va_copy +# ifdef __va_copy +# define va_copy __va_copy +# else +# error "no working va_copy was found" +# endif +#endif + +char * +Xvprintf(const char *format, va_list va) +{ + char *ret; + int size; + va_list va2; + + va_copy(va2, va); + size = vsnprintf(NULL, 0, format, va2); + va_end(va2); + + ret = (char *)Xalloc(size + 1); + if (ret == NULL) + return NULL; + + vsnprintf(ret, size + 1, format, va); + ret[size] = 0; + return ret; +} + +char *Xprintf(const char *format, ...) +{ + char *ret; + va_list va; + va_start(va, format); + ret = Xvprintf(format, va); + va_end(va); + return ret; +} + +char * +XNFvprintf(const char *format, va_list va) +{ + char *ret; + int size; + va_list va2; + + va_copy(va2, va); + size = vsnprintf(NULL, 0, format, va2); + va_end(va2); + + ret = (char *)XNFalloc(size + 1); + if (ret == NULL) + return NULL; + + vsnprintf(ret, size + 1, format, va); + ret[size] = 0; + return ret; +} + +char *XNFprintf(const char *format, ...) +{ + char *ret; + va_list va; + va_start(va, format); + ret = XNFvprintf(format, va); + va_end(va); + return ret; +} diff --git a/nx-X11/programs/Xserver/xkb/ddxLoad.c b/nx-X11/programs/Xserver/xkb/ddxLoad.c index 8e35ab82a..e69d95670 100644 --- a/nx-X11/programs/Xserver/xkb/ddxLoad.c +++ b/nx-X11/programs/Xserver/xkb/ddxLoad.c @@ -719,7 +719,12 @@ char tmpname[PATH_MAX]; } #ifdef TEST - fprintf(stderr, "XkbDDXCompileKeymapByNames: Executing command [%s].\n", buf); + if (buf != NULL) + fprintf(stderr, "XkbDDXCompileKeymapByNames: " + "Executing command [%s].\n", buf); + else + fprintf(stderr, "XkbDDXCompileKeymapByNames: " + "Callin Popen() with null command.\n"); #endif #ifndef WIN32 diff --git a/nx-X11/programs/Xserver/xkb/ddxLoad.c.NX.original b/nx-X11/programs/Xserver/xkb/ddxLoad.c.NX.original index 8e35ab82a..e69d95670 100644 --- a/nx-X11/programs/Xserver/xkb/ddxLoad.c.NX.original +++ b/nx-X11/programs/Xserver/xkb/ddxLoad.c.NX.original @@ -719,7 +719,12 @@ char tmpname[PATH_MAX]; } #ifdef TEST - fprintf(stderr, "XkbDDXCompileKeymapByNames: Executing command [%s].\n", buf); + if (buf != NULL) + fprintf(stderr, "XkbDDXCompileKeymapByNames: " + "Executing command [%s].\n", buf); + else + fprintf(stderr, "XkbDDXCompileKeymapByNames: " + "Callin Popen() with null command.\n"); #endif #ifndef WIN32 -- cgit v1.2.3