Commit Graph

333 Commits

Author SHA1 Message Date
63812b0d21 编译配置 2024-12-26 00:02:41 +08:00
Matthieu Herrb
cdb2f99034 libXfont2 2.0.3
Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
libXfont2-2.0.3
2017-11-25 12:01:16 +01:00
Michal Srb
7b377456f9 Open files with O_NOFOLLOW. (CVE-2017-16611)
A non-privileged X client can instruct X server running under root to open any
file by creating own directory with "fonts.dir", "fonts.alias" or any font file
being a symbolic link to any other file in the system. X server will then open
it. This can be issue with special files such as /dev/watchdog.

Reviewed-by: Matthieu Herrb <matthieu@herrb.eu>
2017-11-25 11:45:41 +01:00
Adam Jackson
d82dfe2549 libXfont 2.0.2
Signed-off-by: Adam Jackson <ajax@redhat.com>
libXfont2-2.0.2
2017-10-11 11:33:29 -04:00
Michal Srb
672bb94431 pcfGetProperties: Check string boundaries (CVE-2017-13722)
Without the checks a malformed PCF file can cause the library to make
atom from random heap memory that was behind the `strings` buffer.
This may crash the process or leak information.

Signed-off-by: Julien Cristau <jcristau@debian.org>
2017-10-04 20:47:13 +02:00
Michal Srb
d1e670a4a8 Check for end of string in PatternMatch (CVE-2017-13720)
If a pattern contains '?' character, any character in the string is skipped,
even if it is '\0'. The rest of the matching then reads invalid memory.

Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Julien Cristau <jcristau@debian.org>
2017-10-04 20:46:08 +02:00
Adam Jackson
9112a6846b readme: Update for libXfont 2.0 interface change
While xfs can be more or less trivially ported to 2.0, bcftopcf cannot
because the font file I/O API is no longer externally visible. This is
intentional, because bdftopcf is literally the only consumer of that
API, and is itself only used in the build process for the classic core
fonts themselves. The plan for bdftopcf is to import a copy of libXfont
1.5 and link against that statically instead.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-04-27 14:52:10 -04:00
Emil Velikov
f8ff8d5f74 autogen.sh: use quoted string variables
Place quotes around the $srcdir, $ORIGDIR and $0 variables to prevent
fall-outs, when they contain space.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-26 12:05:22 +10:00
Peter Hutterer
75b9a15b51 autogen.sh: use exec instead of waiting for configure to finish
Syncs the invocation of configure with the one from the server.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-01-26 12:05:22 +10:00
Adam Jackson
33a98f2b53 freetype: Fix a logic error in computing face name
gcc6 chirps an indentation warning here, but really this is bad code.
Effectively this would ignore en_US or en_UK names for the font, despite
that those are the English names the font is most likely to have.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2016-06-10 09:49:54 -04:00
Adam Jackson
79084468fb autogen: Set a default subject prefix for patches
Signed-off-by: Adam Jackson <ajax@redhat.com>
2016-06-10 09:49:54 -04:00
Adam Jackson
7557fe152d configure: Use -fvisibility=hidden if available
text	   data	    bss	    dec	    hex	filename
 233732	   8168	   1616	 243516	  3b73c	.libs/libXfont2.so.2.before
 217113	   6816	   1616	 225545	  37109	.libs/libXfont2.so.2.after

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2016-06-08 14:03:36 -04:00
Jeremy Huddleston Sequoia
6972ea08ee fserve: Fix a buffer read overrun in _fs_client_access
https://bugs.freedesktop.org/show_bug.cgi?id=83224

Found by clang's Address Sanitizer

	crac.num_auths = set_font_authorizations(&authorizations, &authlen,
						 client);
	/* Work around bug in xfs versions up through modular release 1.0.8
	   which rejects CreateAC packets with num_auths = 0 & authlen < 4 */
	if (crac.num_auths == 0) {
	    authorizations = padding;
	    authlen = 4;
	} else {
	    authlen = (authlen + 3) & ~0x3;
	}
	crac.length = (sizeof (fsCreateACReq) + authlen) >> 2;
	crac.acid = cur->acid;
	_fs_add_req_log(conn, FS_CreateAC);
	_fs_write(conn, (char *) &crac, sizeof (fsCreateACReq));
	_fs_write(conn, authorizations, authlen);

In the case in the report, set_font_authorizations setup authorizations as a
34 byte buffer (and authlen set to 34 as one would expect). The following
block changed authlen to 36 to make it 4byte aligned and the final _fs_write()
caused us to read 36 bytes from this 34 byte buffer.

This changes the incorrect size increase to instead use _fs_write_pad which
takes care of the padding for us.

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2016-05-30 02:10:00 -07:00
Jeremy Huddleston Sequoia
d967caa988 fstrans: Remove unused foo() function
The point of it seems to have been to silence an unused function warning, but
there's no point if we're just transitioning that to another unused function
warning.

src/fc/fstrans.c:32:20: warning: unused function 'foo' [-Wunused-function]
static inline void foo(void) { (void) is_numeric("a"); }
                   ^
1 warning generated.

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2016-05-30 02:09:55 -07:00
Jeremy Huddleston Sequoia
e6009adbc8 fserve: Silence a -Wformat warning
src/fc/fserve.c:653:32: warning: format specifies type 'int' but the argument has type 'CARD32' (aka 'unsigned long') [-Wformat]
               " from font server\n", rep->length);
                                      ^~~~~~~~~~~
1 warning generated.

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2016-05-29 23:37:17 -07:00
Jeremy Huddleston Sequoia
ac559fad20 bitmap: Bail out on invalid input to FontFileMakeDir instead of calling calloc for 0 bytes
Found by clang static analysis:
    Call to 'calloc' has an allocation size of 0 bytes

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2016-05-29 23:35:10 -07:00
Jeremy Huddleston Sequoia
d0fff11199 FreeType: Correct an allocation size
Found by clang static analysis:
    Result of 'calloc' is converted to a pointer of type 'int', which is
    incompatible with sizeof operand type 'int *'

This is likely benign because the old size was larger on any platform where
sizeof(int) <= sizeof(void *), which is everywhere.

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2016-05-29 23:35:02 -07:00
Keith Packard
eefc0b0b90 Revert "Add compiler warning flags". Leave warning fixes.
This reverts commit eb67d10ae8, but
leaves the warning fixes in place; it looks like either I was
confused, or something has changed so that XORG_DEFAULT_OPTIONS now
pulls in the appropriate compiler warnings.
2015-12-12 14:56:03 -08:00
Keith Packard
14488af033 Bump version to 2.0.1
This release just fixes some build issues with 2.0.0

Signed-off-by: Keith Packard <keithp@keithp.com>
libXfont2-2.0.1
2015-12-11 07:09:16 -08:00
Keith Packard
95a40553b8 Remove fontconf.h
This file used to advertise which font formats the library
supports. The X server doesn't care, so let's just remove it so that
it doesn't conflict with the older version of libXfont

Signed-off-by: Keith Packard <keithp@keithp.com>
2015-12-11 07:09:16 -08:00
Matt Turner
903cd14547 Convert to non-recursive build. 2015-12-09 11:39:15 -08:00
Keith Packard
9928d71ec0 Add missing 'attributes.m4' file
Matt Turner noted that this file was missing; 'make distcheck' doesn't
appear to catch this kind of problem.

Signed-off-by: Keith Packard <keithp@keithp.com>
2015-12-09 09:07:30 -08:00
Keith Packard
135fb032e9 Eliminate calls back to X server or font server functions by name (v4)
This eliminates the weak symbol adventures and makes all of the calls
back to the X server or Font server go through a table of functions
instead, clarifying the required API.

As this is a rather major change to the API for the library, it now
installs itself as libXfont2 instead of libXfont, and the package
config file is now xfont2.pc.

All of the installed headers remain the same as the original library;
there's now a new include file, libxfont2.h, which defines the X
server and Font server interfaces.

This moves util/atom.c to stubs/atom.c and reformats that file, hence
the diff being larger than it would otherwise be.

v2: Rename to libXfont2 instead of libXfont_2 as suggested by Emil Velikov
    Fix whitespace in stubs/atom.c, which was moved from util/

v3: Remove select masks from API. Expose single 'font_init' function
    for all library initialization.

v4: Change name of distributed tarballs to libXfont2 as well

Signed-off-by: Keith Packard <keithp@keithp.com>
libXfont2-2.0.0
2015-12-08 20:37:48 -08:00
Keith Packard
eb67d10ae8 Add compiler warning flags and fix warnings
Mostly signed vs unsigned comparisons

Signed-off-by: Keith Packard <keithp@keithp.com>
2015-12-08 20:36:38 -08:00
Jeremy Huddleston Sequoia
d6877a7c1c Use NO_WEAK_SYMBOLS instead of -flat_namespace
Lesser of two evil hacks, I suppose...

This reverts commit 0386fa7736.
2015-10-21 21:28:08 -07:00
Jeremy Huddleston Sequoia
2788c6984b stubs: Add missing externs for declarations in the NO_WEAK_SYMBOLS && PIC stubs resolution
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2015-10-21 21:28:07 -07:00
Thomas Klausner
d66f107d6e Fix is*() usage.
The argument must be an unsigned char or -1; in these cases
we know it's not -1 so cast it to unsigned char.
Fixes
warning: array subscript is of type 'char' [-Wchar-subscripts]

Signed-off-by: Thomas Klausner <wiz@NetBSD.org>
2015-10-20 12:52:08 -04:00
Benjamin Tissoires
1a73d6828d bdfReadCharacters: Allow negative DWIDTH values
The fix for CVE-2015-1804 prevent DWIDTH to be negative.
However, the spec states that "DWIDTH [...] is a vector indicating the
position of the next glyph’s origin relative to the origin of this glyph."

So negative values are correct.

Found by trying to compile XTS.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2015-07-28 16:06:57 -07:00
Alan Coopersmith
159bfa4ec0 doc: add a couple olinks to fsproto & xfs-design docs
Don't seem to have ability to link to BDF or Xserver internals docs yet

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2015-03-20 23:24:05 -07:00
Alan Coopersmith
da4246c98b libXfont 1.5.1
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
libXfont-1.5.1
2015-03-17 08:12:19 -07:00
Alan Coopersmith
2351c83a77 bdfReadCharacters: ensure metrics fit into xCharInfo struct [CVE-2015-1804]
We use 32-bit ints to read from the bdf file, but then try to stick
into a 16-bit int in the xCharInfo struct, so make sure they won't
overflow that range.

Found by afl-1.24b.

v2: Verify that additions won't overflow 32-bit int range either.
v3: As Julien correctly observes, the previous check for bh & bw not
    being < 0 reduces the number of cases we need to check for overflow.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Julien Cristau <jcristau@debian.org>
2015-03-17 08:00:34 -07:00
Alan Coopersmith
78c2e3d70d bdfReadCharacters: bailout if a char's bitmap cannot be read [CVE-2015-1803]
Previously would charge on ahead with a NULL pointer in ci->bits, and
then crash later in FontCharInkMetrics() trying to access the bits.

Found with afl-1.23b.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Julien Cristau <jcristau@debian.org>
2015-03-17 08:00:29 -07:00
Alan Coopersmith
2deda99064 bdfReadProperties: property count needs range check [CVE-2015-1802]
Avoid integer overflow or underflow when allocating memory arrays
by multiplying the number of properties reported for a BDF font.

Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Julien Cristau <jcristau@debian.org>
2015-03-17 08:00:15 -07:00
Christos Zoulas
d9fda3d247 Set close-on-exec for font file I/O.
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Thomas Klausner <wiz@NetBSD.org>
2015-02-26 09:56:26 +01:00
Alan Coopersmith
3b33588117 Use 'imdent' to realign cpp indentation levels in fslibos.h
Parts were indented, others weren't, now is more consistent.
'git diff -w' shows no non-whitespace changes in this commit

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2014-11-05 17:41:24 -08:00
Alan Coopersmith
03c035b061 Remove unneeded checks for #ifndef X_NOT_POSIX
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2014-11-05 17:39:14 -08:00
Alan Coopersmith
ad4f4d8a2d libXfont 1.5.0
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
libXfont-1.5.0
2014-07-19 09:49:23 -07:00
Alan Coopersmith
b19cf2a78f libXfont 1.4.99.901
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
libXfont-1.4.99.901
2014-07-07 13:18:18 -07:00
Yaakov Selkowitz
0dcdd82059 Make shared library work on Cygwin/MinGW
Weak symbols on PE platforms do not work the same way as on ELF
platforms, hence we have been unable to have a fully functional shared
libXfont until now.  This patch works around these issues so that we
can fix that.

In summary, only when compiling shared libraries on NO_WEAK_SYMBOLS
platforms, when the first stub is called, the invoking program is first
checked to determine if it exports the stubbed functions.  Then, for
every stub call, if the function is exported by the loader, it is called
instead of the stub code.

serverClient and serverGeneration are data pointers, and therefore are
replaced by getter functions. ErrorF is variadic, so the override is
routed through VErrorF instead. FatalError has no va_list equivalent,
but it is not actually used in libXfont and therefore should be safe to
remove.

This requires all X servers to export their symbols, which requires
forthcoming patches for hw/xwin and xfs; the other xservers (including
tigervnc) already do this via LD_EXPORT_SYMBOLS_FLAG.

Signed-off-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Tested-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2014-06-27 18:31:56 -05:00
Keith Packard
783a406d62 Use default glyphs when getting 16-bit font with 8-bit text
When accessing a 16-bit font with firstRow > 0 with 8-bit text, check
to see if the font has a default character and return that for every
incoming character.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2014-05-23 17:21:57 -07:00
Alan Coopersmith
e8d20171fe Don't build unused code in bitmapfunc.c if all bitmap formats are disabled
If the only bitmaps we support are builtins, don't need the code to
register all the bitmap font file handlers.

Fixes gcc warnings:
bitmapfunc.c:110:1: warning: 'BitmapOpenBitmap' defined but not used [-Wunused-function]
 BitmapOpenBitmap (FontPathElementPtr fpe, FontPtr *ppFont, int flags,
 ^
bitmapfunc.c:155:1: warning: 'BitmapGetInfoBitmap' defined but not used [-Wunused-function]
 BitmapGetInfoBitmap (FontPathElementPtr fpe, FontInfoPtr pFontInfo,
 ^

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Rémi Cardona <remi@gentoo.org>
2014-05-23 17:21:06 -07:00
Alan Coopersmith
c2b7758d26 Don't compile bitmap source files for disabled formats
pcfread.c is a special case - it's needed for either reading pcf files
from disk (--enable-pcfformat) or from the builtin fonts in memory
(--enable-builtins), so needed a new AM_CONDITIONAL case.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Rémi Cardona <remi@gentoo.org>
2014-05-23 17:21:00 -07:00
Alan Coopersmith
a81f1a9bd3 Drop imake/monolithic compatibility #define mapping
Require the #defines from configure.ac now that we're not sharing source
with the imake builds any longer.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Rémi Cardona <remi@gentoo.org>
2014-05-23 17:20:55 -07:00
Alan Coopersmith
37595cfd4f Change default to disabling SNF support
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Rémi Cardona <remi@gentoo.org>
2014-05-23 17:20:52 -07:00
Alan Coopersmith
9f677e55c7 Use AS_HELP_STRING to provide help for AC_ARG_ENABLE & AC_ARG_WITH options
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Rémi Cardona <remi@gentoo.org>
2014-05-23 17:20:36 -07:00
Alan Coopersmith
d338f81df1 CVE-2014-0210: unvalidated length fields in fs_read_list_info()
fs_read_list_info() parses a reply from the font server.  The reply
contains a number of additional data items with embedded length or
count fields, none of which are validated. This can cause out of
bound reads when looping over these items in the reply.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2014-05-12 23:32:24 -07:00
Alan Coopersmith
5fa73ac184 CVE-2014-0210: unvalidated length fields in fs_read_list()
fs_read_list() parses a reply from the font server.  The reply
contains a list of strings with embedded length fields, none of
which are validated. This can cause out of bound reads when looping
over the strings in the reply.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2014-05-12 23:32:19 -07:00
Alan Coopersmith
5206836525 CVE-2014-0210: unvalidated length fields in fs_read_glyphs()
fs_read_glyphs() parses a reply from the font server.  The reply
contains embedded length fields, none of which are validated.
This can cause out of bound reads when looping over the glyph
bitmaps in the reply.

Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Matthieu Herrb <matthieu@herrb.eu>
2014-05-12 23:32:15 -07:00
Alan Coopersmith
a3f2142153 CVE-2014-0210: unvalidated length fields in fs_read_extent_info()
Looping over the extents in the reply could go past the end of the
reply buffer if the reply indicated more extents than could fit in
the specified reply length.

Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Matthieu Herrb <matthieu@herrb.eu>
2014-05-12 23:32:10 -07:00
Alan Coopersmith
a42f707f8a CVE-2014-0211: integer overflow in fs_alloc_glyphs()
fs_alloc_glyphs() is a malloc wrapper used by the font code.
It contains a classic integer overflow in the malloc() call,
which can cause memory corruption.

Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Matthieu Herrb <matthieu@herrb.eu>
2014-05-12 23:32:04 -07:00