Commit graph

1092 commits

Author SHA1 Message Date
Alan Coopersmith
20c17bd9eb specs/libX11: correct prototype for XListPixmapFormats/XImageByteOrder
The XListPixmapFormats arguments was being shown with XImageByteOrder's
name and return types.   Appears to have been a glitch in the nroff ->
docbook conversion.

Reported-by: ZHANG Zhaolong <zhangzl2013@126.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-06-07 20:12:02 -07:00
Thomas Klausner
ed3d830243 Deal with the limited range of VAX floating point numbers when compiling for VAX.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-06-06 23:11:45 -07:00
Eric S. Raymond
0a48235d63 Remove call to undefined macro. 2013-06-06 16:43:56 -04:00
Eric S. Raymond
9e4719b9b7 Remove call to undefined macro. 2013-06-06 16:42:20 -04:00
Alan Coopersmith
8496122eb0 Update README to reflect where to find the Xlib specs now
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-06-03 20:07:05 -07:00
Alan Coopersmith
655d631e86 libX11 1.6.0
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-06-03 19:21:06 -07:00
Thomas Klausner
4a89b7ea90 cmsMath.c: Add missing stdio header for printf(3) in DEBUG build.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-06-02 16:22:40 -07:00
Thomas Klausner
96dcf747f1 XCreateGC man page: Avoid .TS H and .TH macros
Avoid .TS H and .TH for now as it doesn't alter the output in this case,
and improve the output with mandoc(1).

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-06-02 16:18:33 -07:00
Alan Coopersmith
95a388158c libX11 1.5.99.902 (1.6 RC2)
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-05-23 19:43:42 -07:00
Julien Cristau
a3bdd2b090 xkb: fix off-by-one in _XkbReadGetNamesReply and _XkbReadVirtualModMap
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>
2013-05-23 20:39:46 +02:00
Niveditha Rau
7e30056e78 Make sure internal headers include required headers
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>
2013-05-17 15:27:31 -07:00
Alan Coopersmith
2820100bf8 Free fs->properties in _XF86BigfontQueryFont overflow error path
Fixes small memory leak introduced in commit 5669a22081

Reported-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-05-16 23:05:36 -07:00
Matthieu Herrb
3131740513 XListFontsWithInfo: Re-decrement flist[0] before calling free() on it.
Freeing a pointer that wasn't returned by malloc() is undefined
behavior and produces an error with OpenBSD's implementation.

Signed-off-by: Matthieu Herrb <matthieu.herrb@laas.fr>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-05-09 18:59:54 -07:00
Alan Coopersmith
3fe4bea086 Give GNU & Solaris Studio compilers hints about XEatData branches
Try to offset the cost of all the recent checks we've added by giving
the compiler a hint that the branches that involve us eating data
are less likely to be used than the ones that process it.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-05-09 18:59:54 -07:00
Alan Coopersmith
e1b457beb8 _XkbReadGetMapReply: reject maxKeyCodes smaller than the minKeyCode
Various other bounds checks in the code assume this is true, so
enforce it when we first get the data from the X server.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-05-09 18:59:54 -07:00
Alan Coopersmith
12ad4c6432 Use calloc in XOpenDisplay to initialize structs containing pointers
Prevents trying to free uninitialized pointers if we have to bail out
partway through setup, such as if we receive a corrupted or incomplete
connection setup block from the server.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-05-09 18:59:54 -07:00
Alan Coopersmith
d38527e25f Remove more unnecessary casts from Xmalloc/calloc calls
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-05-09 18:59:54 -07:00
Alan Coopersmith
b2c86b582c Convert more _XEatData callers to _XEatDataWords
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Matthieu Herrb <matthieu.herrb@laas.fr>
2013-05-09 18:59:53 -07:00
Alan Coopersmith
192bbb9e2f Make XGetWindowProperty() always initialize returned values
Avoids memory corruption and other errors when callers access them
without checking to see if XGetWindowProperty() returned an error value.

Callers are still required to check for errors, this just reduces the
damage when they don't.

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>
2013-05-09 18:59:53 -07:00
Alan Coopersmith
db1b1c871d Avoid overflows in XListExtensions() [CVE-2013-1997 15/15]
Ensure that when breaking the returned list into individual strings,
we don't walk past the end of allocated memory to write the '\0' bytes

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Matthieu Herrb <matthieu.herrb@laas.fr>
2013-05-09 18:59:53 -07:00
Alan Coopersmith
8d59365949 Avoid overflows in XGetFontPath() [CVE-2013-1997 14/15]
Ensure that when breaking the returned list into individual strings,
we don't walk past the end of allocated memory to write the '\0' bytes

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Matthieu Herrb <matthieu.herrb@laas.fr>
2013-05-09 18:59:53 -07:00
Alan Coopersmith
0c404db6a9 Avoid overflows in XListFonts() [CVE-2013-1997 13/15]
Ensure that when breaking the returned list into individual strings,
we don't walk past the end of allocated memory to write the '\0' bytes

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Matthieu Herrb <matthieu.herrb@laas.fr>
2013-05-09 18:59:53 -07:00
Alan Coopersmith
0b0f5d4358 integer overflow in XGetModifierMapping() [CVE-2013-1981 13/13]
Ensure that we don't underallocate when the server claims a very large reply

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Matthieu Herrb <matthieu.herrb@laas.fr>
2013-05-09 18:59:53 -07:00
Alan Coopersmith
a351b8103b integer overflow in XGetPointerMapping() & XGetKeyboardMapping() [CVE-2013-1981 12/13]
Ensure that we don't underallocate when the server claims a very large reply

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Matthieu Herrb <matthieu.herrb@laas.fr>
2013-05-09 18:59:53 -07:00
Alan Coopersmith
833f6b70bc integer overflow in XGetImage() [CVE-2013-1981 11/13]
Ensure that we don't underallocate when the server claims to have sent a
very large reply.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Matthieu Herrb <matthieu.herrb@laas.fr>
2013-05-09 18:59:53 -07:00
Alan Coopersmith
79d8dc08eb integer overflow in XGetWindowProperty() [CVE-2013-1981 10/13]
If the reported number of properties is too large, the calculations
to allocate memory for them may overflow, leaving us returning less
memory to the caller than implied by the value written to *nitems.

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>
2013-05-09 18:59:53 -07:00
Alan Coopersmith
164bf4dfe8 integer overflows in TransFileName() [CVE-2013-1981 9/13]
When trying to process file paths the tokens %H, %L, & %S are expanded
to $HOME, the standard compose file path & the xlocaledir path.
If enough of these tokens are repeated and values like $HOME are set to
very large values, the calculation of the total string size required to
hold the expanded path can overflow, resulting in allocating a smaller
string than the amount of data we'll write to it.

Simply restrict all of these values, and the total path size to PATH_MAX,
because really, that's all you should need for a filename path.

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>
2013-05-09 18:59:52 -07:00
Alan Coopersmith
460e8a223b integer truncation in _XimParseStringFile() [CVE-2013-1981 8/13]
Called from _XimCreateDefaultTree() which uses getenv("XCOMPOSEFILE")
to specify filename.

If the size of off_t is larger than the size of unsigned long (as in
32-bit builds with large file flags), a file larger than 4 gigs could
have its size truncated, leading to data from that file being written
past the end of the undersized buffer allocated for it.

While configure.ac does not use AC_SYS_LARGEFILE to set large file mode,
builders may have added the large file compilation flags to CFLAGS on
their own.

size is left limited to an int, because if your Xim file is
larger than 2gb, you're 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>
2013-05-09 18:59:52 -07:00
Alan Coopersmith
226622349a Unbounded recursion in _XimParseStringFile() when parsing include files [CVE-2013-2004 2/2]
parseline() can call _XimParseStringFile() which can call parseline()
which can call _XimParseStringFile() which can call parseline() ....
eventually causing recursive stack overflow and crash.

Limit is set to a include depth of 100 files, which should be enough
for all known use cases, but could be adjusted later if necessary.

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>
2013-05-09 18:59:52 -07:00
Alan Coopersmith
236b603d23 Unbounded recursion in GetDatabase() when parsing include files [CVE-2013-2004 1/2]
GetIncludeFile() can call GetDatabase() which can call GetIncludeFile()
which can call GetDatabase() which can call GetIncludeFile() ....
eventually causing recursive stack overflow and crash.

Easily reproduced with a resource file that #includes itself.

Limit is set to a include depth of 100 files, which should be enough
for all known use cases, but could be adjusted later if necessary.

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>
2013-05-09 18:59:52 -07:00
Alan Coopersmith
076428918e integer overflow in ReadInFile() in Xrm.c [CVE-2013-1981 7/13]
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>
2013-05-09 18:59:52 -07:00
Alan Coopersmith
90fd5abac2 Integer overflows in stringSectionSize() cause buffer overflow in ReadColornameDB() [CVE-2013-1981 6/13]
LoadColornameDB() calls stringSectionSize() to do a first pass over the
file (which may be provided by the user via XCMSDB environment variable)
to determine how much memory needs to be allocated to read in the file,
then allocates the returned sizes and calls ReadColornameDB() to load the
data from the file into that newly allocated memory.

If stringSectionSize() overflows the signed ints used to calculate the
file size (say if you have an xcmsdb with ~4 billion lines in or a
combined string length of ~4 gig - which while it may have been
inconceivable when Xlib was written, is quite possible today), then
LoadColornameDB() may allocate a memory buffer much smaller than the
amount of data ReadColornameDB() will write to it.

The total size is left limited to an int, because if your xcmsdb file
is larger than 2gb, you're 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>
2013-05-09 18:59:52 -07:00
Alan Coopersmith
b9ba832401 unvalidated length in _XimXGetReadData() [CVE-2013-1997 12/15]
Check the provided buffer size against the amount of data we're going to
write into it, not against the reported length from the ClientMessage.

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>
2013-05-09 18:59:52 -07:00
Alan Coopersmith
de2e6c322c unvalidated index/length in _XkbReadGetNamesReply() [CVE-2013-1997 11/15]
If the X server returns key name indexes outside the range of the number
of keys it told us to allocate, out of bounds memory writes could occur.

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>
2013-05-09 18:59:52 -07:00
Alan Coopersmith
2df882eeb3 unvalidated index in _XkbReadVirtualModMap() [CVE-2013-1997 10/15]
If the X server returns modifier map indexes outside the range of the number
of keys it told us to allocate, out of bounds memory writes could occur.

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>
2013-05-09 18:59:52 -07:00
Alan Coopersmith
4d7c422a37 unvalidated index in _XkbReadExplicitComponents() [CVE-2013-1997 9/15]
If the X server returns key indexes outside the range of the number of
keys it told us to allocate, out of bounds memory writes could occur.

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>
2013-05-09 18:59:51 -07:00
Alan Coopersmith
e56a2ada71 unvalidated index in _XkbReadModifierMap() [CVE-2013-1997 8/15]
If the X server returns modifier map indexes outside the range of the number
of keys it told us to allocate, out of bounds memory writes could occur.

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>
2013-05-09 18:59:51 -07:00
Alan Coopersmith
06c086e8a1 unvalidated index in _XkbReadKeyBehaviors() [CVE-2013-1997 7/15]
If the X server returns key behavior indexes outside the range of the number
of keys it told us to allocate, out of bounds memory writes could occur.

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>
2013-05-09 18:59:51 -07:00
Alan Coopersmith
00626c3830 unvalidated index in _XkbReadKeyActions() [CVE-2013-1997 6/15]
If the X server returns key action indexes outside the range of the number
of keys it told us to allocate, out of bounds memory access could occur.

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>
2013-05-09 18:59:51 -07:00
Alan Coopersmith
fd7d4956bc unvalidated index in _XkbReadKeySyms() [CVE-2013-1997 5/15]
If the X server returns keymap indexes outside the range of the number of
keys it told us to allocate, out of bounds memory access could occur.

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>
2013-05-09 18:59:51 -07:00
Alan Coopersmith
59ae16a00d unvalidated indexes in _XkbReadGetGeometryReply() [CVE-2013-1997 4/15]
If the X server returns color indexes outside the range of the number of
colors it told us to allocate, out of bounds memory access could occur.

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>
2013-05-09 18:59:51 -07:00
Alan Coopersmith
bff938b9fe unvalidated indexes in _XkbReadGeomShapes() [CVE-2013-1997 3/15]
If the X server returns shape indexes outside the range of the number
of shapes it told us to allocate, out of bounds memory access could occur.

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>
2013-05-09 18:59:51 -07:00
Alan Coopersmith
f293659d5a unvalidated index in _XkbReadGetDeviceInfoReply() [CVE-2013-1997 2/15]
If the X server returns more buttons than are allocated in the XKB
device info structures, out of bounds writes could occur.

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>
2013-05-09 18:59:51 -07:00
Alan Coopersmith
cddc4e7e3c unvalidated lengths in XAllocColorCells() [CVE-2013-1997 1/15]
If a broken server returned larger than requested values for nPixels or
nMasks, XAllocColorCells would happily overflow the buffers provided by
the caller to write the results into.

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>
2013-05-09 18:59:51 -07:00
Alan Coopersmith
2cd62b5eb9 integer overflow in XListHosts() [CVE-2013-1981 5/13]
If the reported number of host entries is too large, the calculations
to allocate memory for them may overflow, leaving us writing beyond the
bounds of the allocation.

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>
2013-05-09 18:59:50 -07:00
Alan Coopersmith
1f6a3dbf69 integer overflow in XGetMotionEvents() [CVE-2013-1981 4/13]
If the reported number of motion events is too large, the calculations
to allocate memory for them may overflow, leaving us writing beyond the
bounds of the allocation.

v2: Ensure nEvents is set to 0 when returning NULL events pointer

Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-05-09 18:59:50 -07:00
Alan Coopersmith
39515b7c3b integer overflow in XListFontsWithInfo() [CVE-2013-1981 3/13]
If the reported number of remaining fonts is too large, the calculations
to allocate memory for them may overflow, leaving us writing beyond the
bounds of the allocation.

v2: Fix reply_left calculations, check calculated sizes fit in reply_left
v3: On error cases, also set values to be returned in pointer args to 0/NULL

Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-05-09 18:59:50 -07:00
Alan Coopersmith
5669a22081 integer overflow in _XF86BigfontQueryFont() [CVE-2013-1981 2/13]
Similar to _XQueryFont, but with more ways to go wrong and overflow.
Only compiled if libX11 is built with XF86BigFont support.

v2: Fix reply_left calculations, check calculated sizes fit in reply_left

Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-05-09 18:59:50 -07:00
Alan Coopersmith
6df8a63d34 integer overflow in _XQueryFont() on 32-bit platforms [CVE-2013-1981 1/13]
If the CARD32 reply.nCharInfos * sizeof(XCharStruct) overflows an
unsigned long, then too small of a buffer will be allocated for the
data copied in from the reply.

v2: Fix reply_left calculations, check calculated sizes fit in reply_left

Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-05-09 18:59:50 -07:00
Alan Coopersmith
9f5d837065 Add _XEatDataWords to discard a given number of 32-bit words of reply data
Matches the units of the length field in X protocol replies, and provides
a single implementation of overflow checking to avoid having to replicate
those checks in every caller.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Matthieu Herrb <matthieu.herrb@laas.fr>
2013-05-09 18:59:50 -07:00