aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/lib/X11
Commit message (Collapse)AuthorAgeFilesLines
* i18n modules: Fix some const cast warningsAlan Coopersmith2016-10-192-3/+3
| | | | | | | | | | | | imRm.c: In function '_XimSetICMode': imRm.c:2419:37: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual] imRm.c:2420:30: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual] lcGenConv.c: In function 'byteM_parse_codeset': lcGenConv.c:345:13: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual] Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* xlibi18n: Fix a bunch of const cast warningsAlan Coopersmith2016-10-194-20/+17
| | | | | | | | Add const qualifiers to casts where needed, remove other casts that are no longer needed. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* Fix const handling in XSetLocaleModifiersAlan Coopersmith2016-10-191-5/+5
| | | | | | | | | | | | | | Instead of reusing the input parameter to store the output, make a result variable instead, so that there's less const confusion. Fixes gcc warnings: lcWrap.c: In function 'XSetLocaleModifiers': lcWrap.c:87:18: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual] lcWrap.c:91:25: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual] lcWrap.c:93:12: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual] Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* Constify lc_name argument to _XlcLocaleDirName() & _XlcLocaleLibDirName()Alan Coopersmith2016-10-193-61/+35
| | | | | | | | | | | | Makes code considerably less crufty and clears gcc warnings: XlcDL.c: In function '_XlcDynamicLoad': XlcDL.c:384:44: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual] XlcDL.c:386:51: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual] Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* init_om: remove unneeded extra copy of string to local bufferAlan Coopersmith2016-10-191-11/+4
| | | | | | | | | | | | | | Strings from the supported_charset_list[] were being copied one by one to a stack buffer, and then strdup called on that buffer. Instead, just strdup the original string, without the local copy, and use a more traditional for loop, so it's easier to figure out what the code is doing (cleaning up a gcc const-cast warning in the process). Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Matthieu Herrb <matthieu.herrb@laas.fr> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* Delete unused XKB_INSURE_SIZE macro from XKBlibint.hAlan Coopersmith2016-10-191-6/+0
| | | | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Matthieu Herrb <matthieu.herrb@laas.fr> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* miRegionOp(): ensure region size is not updated if realloc failsAlan Coopersmith2016-10-191-2/+3
| | | | | | | | | | | | | This function performs operations on a region, and when finished, checks to see if it should compact the rectangle list. If the number of rectangles for which memory is allocated in the list is more than twice the number used, it tries to shrink. realloc() should not fail in this case, but if it does, might as well keep the correct value for the number of allocated rectangles, so we don't try to grow it unnecessarily later if adding to the region. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* miRegionCopy(): handle realloc failure betterAlan Coopersmith2016-10-191-8/+9
| | | | | | | | | | | Zero out the region size when freeing the region so callers don't think there's anything there. (Pointer is already set to NULL from the realloc result itself.) Return 0 to the callers, and have them cascade that back to their callers to indicate failure, instead of their usual return value of 1 on success. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* Avoid memory leak/corruption if realloc fails in Xregion.h:MEMCHECK macroAlan Coopersmith2016-10-191-3/+4
| | | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* Avoid memory leak/corruption if realloc fails in imLcPrs.c:parseline()Alan Coopersmith2016-10-191-10/+25
| | | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* lcDB.c: ensure buffer size is updated correctly if realloc failsAlan Coopersmith2016-10-191-2/+3
| | | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* Avoid memory leak/corruption if realloc fails in XlcDL.c:resolve_object()Alan Coopersmith2016-10-191-5/+6
| | | | | | | | | | | Previously, if realloc failed to increase the size, we'd still record that we had allocated the larger size, but the pointer to it would be NULL, causing future calls to be broken, and the previous allocation to be lost/leaked. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Matthieu Herrb <matthieu.herrb@laas.fr> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* omGeneric.c: convert sprintf calls to snprintfAlan Coopersmith2016-10-191-10/+11
| | | | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Matthieu Herrb <matthieu.herrb@laas.fr> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* ximcp/imRm.c: convert sprintf calls to snprintfAlan Coopersmith2016-10-191-14/+30
| | | | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Matthieu Herrb <matthieu.herrb@laas.fr> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* xlibi18n: convert sprintf calls to snprintfAlan Coopersmith2016-10-195-57/+51
| | | | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Matthieu Herrb <matthieu.herrb@laas.fr> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* lcfile: skip over any null entries in args listAlan Coopersmith2016-10-191-20/+15
| | | | | | | | | | | | | | | | | | Previous code seemed to assume that printf("%s", NULL) would result in a 0-length string, not "(null)" or similar, but since there's no point looking for files in "(null)/filepath...", instead we just skip over NULL entries in search paths when generating file names. In the *DirName() functions, this effectively just moves the "bail on NULL in arg[i]" check up from the later code that assigned it to targetdir and then bailed if that was NULL. Not sure how there ever could be a NULL in arg[i], given the current implementation of XlcParsePath, but it's easy enough to check once and reject up front instead of on every reference. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* Fix file leak on malloc error in XlcDL.c:resolve_object()Alan Coopersmith2016-10-191-1/+3
| | | | | | | | | | | | | File Leak: Leaked File fp at line 219 of lib/libX11/nx-X11/lib/X11/XlcDL.c in function 'resolve_object'. fp initialized at line 198 with fopen [ This bug was found by the Parfait 1.2.0 bug checking tool. http://labs.oracle.com/pls/apex/f?p=labs:49:::::P49_PROJECT_ID:13 ] Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Matthieu Herrb <matthieu.herrb@laas.fr> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* Fix bogus timestamp generated by XIMISHIKAWA,chiaki2016-10-192-0/+21
| | | | | | | | | | Fix bogus timestamp generted by XIM due to uninitialized data field. Also set appropriate serial, too. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=39367 Signed-off-by: Chiaki ISHIKAWA <ishikawa@yk.rim.or.jp> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* XIM: Fix race on focus change: set 'FABRICATED' only when keyev filters in ↵Egbert Eich2016-10-191-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | place. When synthesized key events are sent on commit XIM sets the 'fabricated' flag so that the keypress handler knows that these were not real events. This also happens when committing due to the loss of focus. However in this case the keypress/release filters which consume and unset this flag are no longer in the filter chain. So the flag is erronously set when a real keyboard event is received after focus has been regained. So the first event is wrongly treated as a fabricated key in the keypress handler which will at the same time reset the flag so the second key event is treated correctly. This fix only sets the flag when at least one of the keyboard filters is in place. How to reproduce this bug: run scim, choose a Japanese input method start two instances of xterm: start typing in one xterm (this should pop up an IM window). Without comitting (hitting 'enter') move focus to the other xterm, then move focus back. Start typing again. The first character will be committed immediately without popping up an input window. With this fix this behavior is gone. See also: https://bugzilla.novell.com/show_bug.cgi?id=239698 Signed-off-by: Egbert Eich <eich@freedesktop.org> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* omGeneric: remove space between struct name & member nameAlan Coopersmith2016-10-191-1/+1
| | | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* XSetModifierMapping: Use Data instead of GetReqExtraAlan Coopersmith2016-10-191-9/+3
| | | | | | | | Handle arbitrary length data in the same fashion as other calls, avoiding need to ensure it fits all in the request buffer. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* libX11: check size of GetReqExtra after XFlushKees Cook2016-10-192-3/+15
| | | | | | | | | | | | | | | | | | | | | | | Two users of GetReqExtra pass arbitrarily sized allocations from the caller (ModMap and Host). Adjust _XGetRequest() (called by the GetReqExtra macro) to double-check the requested length and invalidate "req" when this happens. Users of GetReqExtra passing lengths greater than the Xlib buffer size (normally 16K) must check "req" and fail gracefully instead of crashing. Any callers of GetReqExtra that do not check "req" for NULL will experience this change, in the pathological case, as a NULL dereference instead of a buffer overflow. This is an improvement, but the documentation for GetReqExtra has been updated to reflect the need to check the value of "req" after the call. Bug that manifested the problem: https://bugs.launchpad.net/ubuntu/+source/x11-xserver-utils/+bug/792628 Signed-off-by: Kees Cook <kees@outflux.net> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* Tighten out-of-range comparisons.Thomas Klausner2016-10-194-4/+4
| | | | | | | | | | | | | [For all of these, LONG_MAX was the correct value to prevent overflows for the recent CVEs. Lowering to INT_MAX catches buggy replies from the server that 32-bit clients would reject but 64-bit would accept, so we catch bugs sooner, and really, no sane & working server should ever report more than 2gb of extension names, font path entries, key modifier maps, etc. -alan- ] Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* Fix out-of-range comparison in _XF86BigfontQueryFontThomas Klausner2016-10-191-1/+1
| | | | | | | | | | | | | | | | | clang complained (correctly): warning: comparison of constant 768614336404564650 with expression of type 'CARD32' (aka 'unsigned int') is always true [-Wtautological-constant-out-of-range-compare] [While LONG_MAX is correct, since it's used in size_t math, the numbers have to be limited to 32-bit range to be usable by 32-bit clients, and values beyond that range are far more likely to be bugs in the data from the server than valid numbers of characters in a font. -alan- ] Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* Check for symbol existence with #ifdef, not #ifThomas Klausner2016-10-191-1/+1
| | | | | | | Reviewed-by: Jamey Sharp <jamey@minilop.net> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* Stop truncating source to destination length if it is larger.Thomas Klausner2016-10-191-28/+0
| | | | | | | | | | It seems useless to do that since the code tests for both source length and destination to be non-zero. This fixes a cut'n'paste problem in xterm where the paste length was limited to 1024 (BUFSIZ) in button.c. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* Require ANSI C89 pre-processor, drop pre-C89 token pasting supportAlan Coopersmith2016-10-193-40/+0
| | | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* Align files with upstream libX11-1.6.0Ulrich Sibiller2016-10-1942-194/+190
| | | | | | | | | | | | This commit looks a bit crazy at first glance. It (re-)introduces lots of whitespaces and bad formatting. Explanation: Backporting upstream changes lead to commits being applied out of order. This meant a lot of manual intervention which in turn lead to slight differences between upstream and NX. With this commit these slight differences are minimized which will be of great help when adding further upstream patches.
* Tell clang not to report -Wpadded warnings on public headers we can't fixAlan Coopersmith2016-10-194-0/+48
| | | | | | | Better to silence the compiler warning than break ABI. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* Zero buffer data in BufAlloc()Adam Jackson2016-10-191-1/+1
| | | | | | | | | | | Inspired by a pattern in NoMachine's NX. Consistently zeroed buffers compress better with ssh and friends. Note that you'll need to rebuild all your protocol libraries to take advantage of this. Signed-off-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* GetProp: Zero-initialized error so its resourceID field is initializedErkki Seppälä2016-10-191-1/+1
| | | | | | | | | | Using uninitialized value "error.resourceID" in call to function "_XError" Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Erkki Seppälä <erkki.seppala@vincit.fi> Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan-de-oliveira@nokia.com> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* integer overflow in ReadInFile() in Xrm.c [CVE-2013-1981 7/13]Alan Coopersmith2016-10-191-2/+4
| | | | | | | | | | | | | | | | | | Called from XrmGetFileDatabase() which gets called from InitDefaults() which gets the filename from getenv ("XENVIRONMENT") If file is exactly 0xffffffff bytes long (or longer and truncates to 0xffffffff, on implementations where off_t is larger than an int), then size may be set to a value which overflows causing less memory to be allocated than is written to by the following read() call. size is left limited to an int, because if your Xresources file is larger than 2gb, you're very definitely doing it wrong. Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Matthieu Herrb <matthieu.herrb@laas.fr> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* ximcp/imRmAttr: Handle leaking colormap_retErkki Seppälä2016-10-191-1/+3
| | | | | | | | | | | XFree colormap_ret and initialize it when appropriate. Variable "colormap_ret" goes out of scope Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Signed-off-by: Erkki Seppälä <erkki.seppala@vincit.fi> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* Fix status reporting for braille patternsSamuel Thibault2016-10-191-10/+20
| | | | | | | | | _XimLocalMbLookupString can return a braille keysym even if _Xlcwctomb can't convert to the current MB charset. _XimLocalUtf8LookupString needs to set the braille keysym and status too. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* Revert incomplete "Fix status reporting for braille patterns"Ulrich Sibiller2016-10-191-20/+6
| | | | | | | This reverts commit 8866f80d9f42e02093058cab027edbf127118105. That commit had been edited and was incomplete, by reverting and re-applying we get it right.
* Sun's copyrights are now owned by OracleAlan Coopersmith2016-10-1916-16/+16
| | | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* Assume size_t is always available, since it was defined in C89Ulrich Sibiller2016-10-191-8/+2
| | | | | | We have the same commit for XKBGAlloc.c but it was missing here since upstream has dropped OpenDis.c when they switched to XCB. Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* rename xf86bigfstr.h to xf86bigfproto.hUlrich Sibiller2016-10-191-1/+1
|
* cmsMath.c: Add missing stdio header for printf(3) in DEBUG build.Thomas Klausner2016-10-191-0/+4
| | | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* Make sure internal headers include required headersNiveditha Rau2016-10-198-0/+15
| | | | | | | | | | Fixes builds with Solaris Studio 12.3 when lint is enabled, since it no longer ignores *.h files, but complains when they reference undefined typedefs or macros. Signed-off-by: Niveditha Rau <Niveditha.Rau@Oracle.COM> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* Free fs->properties in XF86BigfontQueryFont overflow error pathAlan Coopersmith2016-10-191-0/+1
| | | | | | | | | | | Fixes small memory leak introduced in commit 5669a22081 Reported-by: Julien Cristau <jcristau@debian.org> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Hint: Upstream commit 5669a22081 is "integer overflow in _XF86BigfontQueryFont() [CVE-2013-1981 2/13]" Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* xkb: fix off-by-one in _XkbReadGetNamesReply and _XkbReadVirtualModMapJulien Cristau2016-10-192-2/+2
| | | | | | | | | | | | The size of the arrays is max_key_code + 1. This makes these functions consistent with the other checks added for CVE-2013-1997. Also check the XkbGetNames reply when names->keys was just allocated. Signed-off-by: Julien Cristau <jcristau@debian.org> Tested-by: Colin Walters <walters@verbum.org> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* Revert "Add a couple fixups for the security patches"Ulrich Sibiller2016-10-193-3/+2
| | | | | | This reverts commit b092864a39bbcd4f34c5c26a7cd0df90e235815d. We will use the proper libX11 upstream patches now.
* Remove more unnecessary casts from Xmalloc/calloc callsAlan Coopersmith2016-10-1933-132/+112
| | | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* Move big request comment in XOpenDisplay to the right placeAlan Coopersmith2016-10-191-1/+3
| | | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* Fix very weird indenting in nx-X11/lib/X11/GetFProp.cAlan Coopersmith2016-10-191-12/+12
| | | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* XAllocClassHint: Assume calloc sets pointers in allocated memory to NULLAlan Coopersmith2016-10-191-6/+1
| | | | | | | | | | | While the C standard technically allows for the compiler to translate pointer = 0 or pointer = NULL into something other than filling the pointer address with 0 bytes, the rest of the Xlib code already assumes that calloc initializes any pointers in the struct to NULL, and there are no known systems supported by X.Org where this is not true. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* _xudc_code_to_glyph: check for NULL pointer *before* writing to it, not afterAlan Coopersmith2016-10-191-4/+4
| | | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* Assume size_t is always available, since it was defined in C89Alan Coopersmith2016-10-191-8/+1
| | | | | | | | | Don't provide a fallback definition #ifdef X_NOT_POSIX anymore. We already use size_t throughout the rest of Xlib, just had this one instance left in XKBGAlloc.c of a fallback definition. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
* unifdef XKB_IN_SERVERAlan Coopersmith2016-10-194-50/+0
| | | | | | | | | Leftovers from XKB files that were previously shared between the client and server code, but aren't any more. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>