Commit graph

1384 commits

Author SHA1 Message Date
Alan Coopersmith
a4a7df0635 XlibInt.c: include headers needed for ioctl(...FIONREAD...) on Solaris
Fixes: commit 5538b3e4ae

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-02-23 11:43:51 -08:00
Alan Coopersmith
38ec04de7e specs/XKB: Fix misprint in documentation of XkbFreeGeomOverlayKeys()
Fixes: https://gitlab.freedesktop.org/xorg/lib/libx11/issues/86
aka: https://bugs.freedesktop.org/show_bug.cgi?id=23550

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-02-23 11:43:51 -08:00
Alan Coopersmith
74f2f26811 specs/XKB: Fix misprint in documentation of XkbAllocGeomOverlayKeys()
Fixes: https://gitlab.freedesktop.org/xorg/lib/libx11/issues/85
aka: https://bugs.freedesktop.org/show_bug.cgi?id=23549

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-02-23 11:43:51 -08:00
Alan Coopersmith
66b039a416 specs/XKB: Fix misprint in documentation of XkbAllocGeomOverlayRows()
Fixes: https://gitlab.freedesktop.org/xorg/lib/libx11/issues/84
aka: https://bugs.freedesktop.org/show_bug.cgi?id=23548

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-02-23 11:43:51 -08:00
Alan Coopersmith
cdea0e8403 specs/XKB: Fix misprint in documentation of XkbGetNamedGeometry()
Fixes: https://gitlab.freedesktop.org/xorg/lib/libx11/issues/82
aka: https://bugs.freedesktop.org/show_bug.cgi?id=23520

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-02-23 11:43:51 -08:00
Alan Coopersmith
c72d17ada9 XkbAllocGeomOverlayKey man page should be named XkbAllocGeomOverlayKeys
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-02-23 11:43:35 -08:00
Alan Coopersmith
05002b8aef Fix man page typo: XkbAllBellNotifyMask -> XkbAllBellEventsMask
Reported-by: Daniel Hahler <git@thequod.de>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-02-17 15:14:14 -08:00
Adam Jackson
5538b3e4ae _XDefaultIOError: Do better at detecting explicit shutdown
Currently, when the X server crashes or a client is disconnected with
XKillClient, you get a somewhat confusing error message from libX11
along the lines of:

XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":0"
      after 98 requests (40 known processed) with 0 events remaining.

What's happening here is the previous recvmsg has thrown EAGAIN, since
the socket is non-blocking. In this case, check whether the socket has
any more data to read, and if not treat it like EPIPE.

Signed-off-by: Adam Jackson <ajax@redhat.com>
2019-01-16 11:45:34 -05:00
Adam Jackson
6d2cde9633 _XDefaultIOError: Reformat to be less ugly
Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-01-16 11:45:34 -05:00
Alan Coopersmith
003e30a66a Avoid use-after-free in _XimProtoSetIMValues()
Fixes gitlab issue #49

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-01-01 14:34:04 -08:00
Alan Coopersmith
30656fd66a Fix implicit conversion warnings in _XlcCreateDefaultCharSet
lcCharSet.c:187:50: warning: implicit conversion changes signedness:
      'int' to 'unsigned long' [-Wsign-conversion]
    tmp = Xmalloc(name_len + 1 + ct_sequence_len + 1);
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
../../include/X11/Xlibint.h:453:32: note: expanded from macro 'Xmalloc'
                       ~~~~~~  ^~~~
lcCharSet.c:192:31: warning: implicit conversion changes signedness:
      'int' to 'unsigned long' [-Wsign-conversion]
    memcpy(tmp, name, name_len+1);
    ~~~~~~            ~~~~~~~~^~
lcCharSet.c:216:45: warning: implicit conversion changes signedness:
      'int' to 'unsigned long' [-Wsign-conversion]
    memcpy(tmp, ct_sequence, ct_sequence_len+1);
    ~~~~~~                   ~~~~~~~~~~~~~~~^~
lcCharSet.c:183:16: warning: implicit conversion loses integer precision:
      'unsigned long' to 'int' [-Wshorten-64-to-32]
    name_len = strlen(name);
             ~ ^~~~~~~~~~~~
lcCharSet.c:184:23: warning: implicit conversion loses integer precision:
      'unsigned long' to 'int' [-Wshorten-64-to-32]
    ct_sequence_len = strlen(ct_sequence);
                    ~ ^~~~~~~~~~~~~~~~~~~
lcCharSet.c:198:37: warning: implicit conversion loses integer precision:
     'long' to 'unsigned int' [-Wshorten-64-to-32]
        unsigned int length = colon - charset->name;
                     ~~~~~~   ~~~~~~^~~~~~~~~~~~~~~

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-01-01 12:22:32 -08:00
Alan Coopersmith
2e63009057 Remove no-longer-used name variable in _XGetAtomName
Fixes gcc warning:
GetAtomNm.c: In function ‘_XGetAtomName’:
GetAtomNm.c:39:11: warning: unused variable ‘name’ [-Wunused-variable]
     char *name;
           ^~~~

Introduced by commit 336c1e7a50

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-01-01 11:41:47 -08:00
Alan Coopersmith
f077871c2a Fix out-of-tree builds after commit 8a62e26515
In-tree builds found reallocarray.h in $(top_builddir)/src but the
out-of-tree build didn't find it at all.

Reported-by: Emmanuele Bassi <ebassi@gmail.com> from GNOME continuous integration pipeline
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2018-12-29 11:40:50 -08:00
Alan Coopersmith
ba7f7cc783 Convert src/xlibi18n to use reallocarray()
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2018-12-08 10:06:42 -08:00
Alan Coopersmith
336c1e7a50 Replace Xmalloc+strcpy pairs with strdup calls
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2018-12-08 10:06:42 -08:00
Alan Coopersmith
258a8ced68 Replace _XkbTypedRealloc & _XkbClearElems with new _XkbResizeArray
Makes resizing & clearing more consistent and gets rid of some weird
quirks like always subtracting 1 from the size passed to _XkbClearElems
so it could always add 1 to the size passed in.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2018-12-08 10:06:42 -08:00
Alan Coopersmith
f94273e2f4 Add some missing allocation failure checks in src/xcms
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2018-12-08 10:06:42 -08:00
Alan Coopersmith
76850471b4 Convert src/xcms to use reallocarray()
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2018-12-08 10:06:42 -08:00
Alan Coopersmith
8a62e26515 Convert src/XKB to use reallocarray()
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2018-12-08 10:06:42 -08:00
Alan Coopersmith
6d1dc1f616 Convert main src directory to use reallocarray() 2018-12-08 10:06:42 -08:00
Alan Coopersmith
bcf7b5aa06 Import reallocarray() from OpenBSD
Wrapper for realloc() that checks for overflow when multiplying
arguments together, so we don't have to add overflow checks to
every single call.  For documentation on usage, see:
http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man3/calloc.3

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2018-12-08 10:04:13 -08:00
Alan Coopersmith
9bdfe9c9af Update README for gitlab migration
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2018-11-19 21:26:23 -08:00
Albert Astals Cid
c8bcc19970 locale.dir: Add ast_ES.UTF-8
With this patch xev properly reports
   XLookupString gives 2 bytes: (c2 b4) "´"
for the dead_acute key when using the Asturian locale
2018-11-12 18:02:40 +00:00
Albert Astals Cid
117bb310b4 compose.dir: Add ast_ES.UTF-8
With this patch one can properly type dead keys like á when using the
Asturian locale
2018-11-12 18:02:40 +00:00
Alan Coopersmith
d7e22252d6 Remove documentation of obsolete B16 & B32 tags in specs/libX11
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2018-11-10 13:30:47 -08:00
Matt Turner
f3c978476e libX11 1.6.7
Signed-off-by: Matt Turner <mattst88@gmail.com>
2018-10-09 10:26:12 -04:00
Michel Dänzer
823a0f8a82 poll_for_event: Allow using xcb_poll_for_queued_event
It avoids reading from the display connection again in cases where that
was already done.

Suggested-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Uli Schlachter <psychon@znc.in>
2018-09-28 17:24:17 +02:00
Michel Dänzer
406afe4b0f poll_for_response: Call poll_for_event again if xcb_poll_for_reply fails
If xcb_poll_for_reply fails to find a reply, poll_for_response would
always return NULL. However, xcb_poll_for_reply may have read events
from the display connection while looking for a reply. In that case,
returning NULL from poll_for_response is wrong and can result in the
client hanging, e.g. because it returns to waiting for the display
connection file descriptor becoming readable after XPending incorrectly
returned 0 pending events.

The solution is to call poll_for_event again after xcb_poll_for_reply
returned 0. This will return the first of any events read by
xcb_poll_for_reply.

Fixes issue #79.

Reported-by: Yuxuan Shui <yshuiv7@gmail.com>
Bugzilla: https://bugs.freedesktop.org/108008
Bugzilla: https://bugs.freedesktop.org/107992
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-09-25 17:10:58 +02:00
Bhavi Dhingra
d0416863d5 XcmsLookupColor: fully initialize XColor structs passed to _XColor_to_XcmsRGB
Fixes https://gitlab.freedesktop.org/xorg/lib/libx11/issues/44
aka https://bugs.freedesktop.org/show_bug.cgi?id=92154

Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2018-09-22 16:21:14 -07:00
Matthieu Herrb
733f64bfeb libX11 1.6.6
Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
2018-08-21 16:54:50 +02:00
Matthieu Herrb
173704243f Remove statement with no effect.
Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
2018-08-21 16:53:40 +02:00
Tobias Stoeckmann
e83722768f Fixed crash on invalid reply (CVE-2018-14598).
If the server sends a reply in which even the first string would
overflow the transmitted bytes, list[0] (or flist[0]) will be set to
NULL and a count of 0 is returned.

If the resulting list is freed with XFreeExtensionList or
XFreeFontPath later on, the first Xfree call:

    Xfree (list[0]-1)
 turns into
    Xfree (NULL-1)

which will most likely trigger a segmentation fault.

I have modified the code to return NULL if the first string would
overflow, thus protecting the freeing functions later on.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2018-08-21 16:43:22 +02:00
Tobias Stoeckmann
dbf72805fd Fixed out of boundary write (CVE-2018-14600).
The length value is interpreted as signed char on many systems
(depending on default signedness of char), which can lead to an out of
boundary write up to 128 bytes in front of the allocated storage, but
limited to NUL byte(s).

Casting the length value to unsigned char fixes the problem and allows
string values with up to 255 characters.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2018-08-21 16:43:06 +02:00
Tobias Stoeckmann
b469da1430 Fixed off-by-one writes (CVE-2018-14599).
The functions XGetFontPath, XListExtensions, and XListFonts are
vulnerable to an off-by-one override on malicious server responses.

The server replies consist of chunks consisting of a length byte
followed by actual string, which is not NUL-terminated.

While parsing the response, the length byte is overridden with '\0',
thus the memory area can be used as storage of C strings later on. To
be able to NUL-terminate the last string, the buffer is reserved with
an additional byte of space.

For a boundary check, the variable chend (end of ch) was introduced,
pointing at the end of the buffer which ch initially points to.
Unfortunately there is a difference in handling "the end of ch".

While chend points at the first byte that must not be written to,
the for-loop uses chend as the last byte that can be written to.

Therefore, an off-by-one can occur.

I have refactored the code so chend actually points to the last byte
that can be written to without an out of boundary access. As it is not
possible to achieve "ch + length < chend" and "ch + length + 1 > chend"
with the corrected chend meaning, I removed the inner if-check.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2018-08-21 16:42:29 +02:00
Tobias Stoeckmann
d81da209fd Validation of server response in XListHosts.
If a server sends an incorrect length in its response, a client is prone
to perform an out of boundary read while processing the data.

The length field of xHostEntry is used to specify the amount of bytes
used to represent the address. It is 16 bit, which means that it is not
possible to perform an arbitrary memory access, but it might be enough
to read sensitive information, e.g. malloc-related pointers and offsets.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Matthieu Herrb <matthieu@herrb.eu>
2018-07-17 15:23:14 +02:00
Samuel Thibault
b676e62377 XkbOpenDisplay.3: fix typo
XkbOpenDisplay returns a pointer to Display, not a Display.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2018-06-13 15:46:58 +02:00
Martin Natano
9c5845ff0d Don't rebuild ks_tables.h if nothing changed.
ks_tables.h is always considered out of date due to the forced rebuild
of the makekeys util. This means the file is also rebuilt during 'make
install', which is usually performed as root, which can to lead
permission problems later on.

Signed-off-by: Martin Natano <natano@natano.net>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2018-05-13 18:38:58 -07:00
Alan Coopersmith
796f754cba Change fall through comment in lcDB.c to match gcc's requirements
Needs to match one of the regexps shown under
https://gcc.gnu.org/onlinedocs/gcc-7.3.0/gcc/Warning-Options.html#index-Wimplicit-fallthrough

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2018-05-05 14:45:57 -07:00
Alan Coopersmith
82ca630875 Use size_t for buffer sizes in SetHints.c
These variables store values returned from strlen() as a size_t
and are passed to Xmalloc, which expects a size_t, so lets stop
converting back and forth to int along the way.

Reported by: Konstantin SKliarov
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Matthieu Herrb <matthieu@herrb.eu>
2018-03-30 15:46:18 -07:00
Bhavi Dhingra
50a5a98984 Fix possible memory leak in cmsProp.c:140
https://bugs.freedesktop.org/show_bug.cgi?id=96814

Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2018-03-24 11:13:46 -07:00
Michal Srb
a9dafdd57c Use flexible array member instead of fake size.
The _XimCacheStruct structure is followed in memory by two strings containing
fname and encoding. The memory was accessed using the last member of the
structure `char fname[1]`. That is a lie, prohibits us from using sizeof and
confuses checkers. Lets declare it properly as a flexible array, so compilers
don't complain about writing past that array. As bonus we can replace the
XOffsetOf with regular sizeof.

Fixes GCC8 error:
  In function 'strcpy',
      inlined from '_XimWriteCachedDefaultTree' at imLcIm.c:479:5,
      inlined from '_XimCreateDefaultTree' at imLcIm.c:616:2,
      inlined from '_XimLocalOpenIM' at imLcIm.c:700:5:
  /usr/include/bits/string_fortified.h:90:10: error: '__builtin_strcpy'
  forming offset 2 is out of the bounds [0, 1] [-Werror=array-bounds]
     return __builtin___strcpy_chk (__dest, __src, __bos (__dest));

Caused by this line seemingly writing past the fname[1] array:
  imLcIm.c:479:  strcpy (m->fname+strlen(name)+1, encoding);

Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-23 14:32:05 +10:00
Alan Coopersmith
34f4464f69 If XGetImage fails to create image, don't dereference it to bounds check
Reported by gcc 7.3:

GetImage.c:110:25: warning: potential null pointer dereference [-Wnull-dereference]
  if (planes < 1 || image->height < 1 || image->bytes_per_line < 1 ||
                    ~~~~~^~~~~~~~

Introduced by 8ea762f94f in Xlib 1.6.4

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2018-03-07 14:50:32 -08:00
wharms
e835a9dcc3 silence gcc warning assignment discards 'const' qualifier from pointer target type 2017-09-03 14:17:45 +02:00
wharms
36a1ac0253 remove empty line 2017-08-20 21:51:57 +02:00
wharms
e02dfe54f3 add _X_UNUSED to avoid unused variable warnings 2017-08-20 21:50:33 +02:00
walter harms
2911c39cec Fixes: warning: variable 'req' set but not,used
Fixes: warning: variable 'req' set but not used [-Wunused-but-set-variable]
       by marking req _X_UNUSED
	Solution was discussed on xorg-devel ML
       Peter Hutter, Alan Coopersmith
        Re: [PATCH libX11 3/5] fix: warning: pointer targets in passing argument 2 of '_XSend' differ in signedness [-Wpointer-sign]

Signed-off-by: harms wharms@bfs.de
2017-08-20 21:47:05 +02:00
walter harms
bf82ec0402 mark _XDefaultIOError as no_return
mark _XDefaultIOError as no_return. No one comes back from exit() ...

Signed-off-by: harms wharms@bfs.de
2017-08-20 21:44:26 +02:00
walter harms
9abe838007 no need to check XFree arguments
You can save a bit of code. The is no need to check XFree arguments bring  free_fontdataOM in line with other free function and check for NULL arg

Signed-off-by: harms wharms@bfs.de
2017-08-20 21:41:41 +02:00
walter harms
433477fcb7 fix memleak in error path
free all mem on error
Signed-off-by: walter harms <wharms@bfs.de>
2017-08-14 18:54:44 +02:00
walter harms
ed9f0d34ab fix memleak in error path
V2: remove unneeded NULL (reported by eric.engestrom@imgtec.com)

fix mem leak in error path
Signed-off-by: walter harms <wharms@bfs.de>
2017-08-14 18:28:18 +02:00