+++ /dev/null
-#
-# X.Org module default exclusion patterns
-# The next section if for module specific patterns
-#
-# Do not edit the following section
-# GNU Build System (Autotools)
-aclocal.m4
-autom4te.cache/
-autoscan.log
-ChangeLog
-compile
-config.guess
-config.h
-config.h.in
-config.log
-config-ml.in
-config.py
-config.status
-config.status.lineno
-config.sub
-configure
-configure.scan
-depcomp
-.deps/
-INSTALL
-install-sh
-.libs/
-libtool
-libtool.m4
-ltmain.sh
-lt~obsolete.m4
-ltoptions.m4
-ltsugar.m4
-ltversion.m4
-Makefile
-Makefile.in
-mdate-sh
-missing
-mkinstalldirs
-*.pc
-py-compile
-stamp-h?
-symlink-tree
-texinfo.tex
-ylwrap
-
-# Do not edit the following section
-# Edit Compile Debug Document Distribute
-*~
-*.[0-9]
-*.[0-9]x
-*.bak
-*.bin
-core
-*.dll
-*.exe
-*-ISO*.bdf
-*-JIS*.bdf
-*-KOI8*.bdf
-*.kld
-*.ko
-*.ko.cmd
-*.lai
-*.l[oa]
-*.[oa]
-*.obj
-*.patch
-*.so
-*.pcf.gz
-*.pdb
-*.tar.bz2
-*.tar.gz
-#
-# Add & Override patterns for libXfont
-#
-# Edit the following section as needed
-# For example, !report.pc overrides *.pc. See 'man gitignore'
-#
but should not be used by normal X11 clients. X11 clients access fonts
via either the new API's in libXft, or the legacy API's in libX11.
+libXfont supports a number of compression and font formats, and the
+configure script takes various options to enable or disable them:
+
+ -- Compression types:
+
+ gzip - always enabled, no option to disable, requires libz
+
+ bzip2 - disabled by default, enable via --with-bzip2, requires libbz2
+
+ -- Font formats:
+
+ builtins - copies of the "fixed" & "cursor" fonts required by the
+ X protocol are built into the library so the X server always
+ has the fonts it requires to start up. Accessed via the
+ special 'built-ins' entry in the X server font path.
+ Enabled by default, disable via --disable-builtins.
+
+ freetype - handles scalable font formats including OpenType, FreeType,
+ and PostScript formats. Requires FreeType2 library.
+ Can also be used to handle bdf & bitmap pcf font formats.
+ Enabled by default, disable via --disable-freetype.
+
+ bdf bitmap fonts - text file format for distributing fonts, described
+ in http://www.x.org/docs/BDF/bdf.pdf specification. Normally
+ not used by the X server at runtime, as the fonts distributed
+ by X.Org in bdf format are compiled with bdftopcf when
+ installing/packaging them.
+ Enabled by default, disable via --disable-bdfformat.
+
+ pcf bitmap fonts - standard bitmap font format since X11R5 in 1991,
+ used for all bitmap fonts installed from X.Org packages.
+ Compiled format is architecture independent.
+ As noted above, usually produced by bdftopcf.
+ Enabled by default, disable via --disable-pcfformat.
+
+ snf bitmap fonts - standard bitmap font format prior to X11R5 in 1991,
+ remains only for backwards compatibility. Unlike pcf, snf files
+ are architecture specific, and contain less font information
+ than pcf files. snf fonts are deprecated and support for them
+ may be removed in future libXfont releases.
+ Disabled by default, enable via --disable-snfformat.
+
+ -- Font services:
+
+ xfs font servers - allows retreiving fonts as a client of an xfs server.
+ Enabled by default, disable via --disable-fc (font client).
+
+ If enabled, you can also use the standard libxtrans flags to
+ configure which transports can be used to connect to xfs:
+ --enable-unix-transport Enable UNIX domain socket transport
+ --enable-tcp-transport Enable TCP socket transport (IPv4)
+ --enable-ipv6 Enable IPv6 support for tcp-transport
+ --enable-local-transport Enable os-specific local transport
+ (Change --enable to --disable to force disabling support.)
+ The default setting is to enable all of the transports the
+ configure script can find OS support for.
+
+--------------------------------------------------------------------------
+
Please submit bugs & patches to the Xorg bugzilla:
https://bugs.freedesktop.org/enter_bug.cgi?product=xorg
# Initialize Autoconf
AC_PREREQ([2.60])
-AC_INIT([libXfont], [1.4.7],
+AC_INIT([libXfont], [1.5.0],
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libXfont])
AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_HEADERS([config.h include/X11/fonts/fontconf.h])
XFONT_FONTFILE=no
#
-# Scalable fonts in files:
-# FreeType
-# Bitstream Speedo rasterizer
+# FreeType for all scalable (OpenType, TrueType, PostScript) and
+# some bitmap formats (BDF & PCF)
#
-AC_ARG_ENABLE(freetype, [ --disable-freetype],[XFONT_FREETYPE=$enableval],[XFONT_FREETYPE=yes])
+AC_ARG_ENABLE(freetype,
+ AS_HELP_STRING([--disable-freetype],
+ [Build freetype backend (default: enabled)]),
+ [XFONT_FREETYPE=$enableval],[XFONT_FREETYPE=yes])
AM_CONDITIONAL(XFONT_FREETYPE, [test x$XFONT_FREETYPE = xyes])
if test x$XFONT_FREETYPE = xyes; then
AC_DEFINE(XFONT_FREETYPE,1,[Support FreeType rasterizer for nearly all font file formats])
- AC_ARG_WITH(freetype-config, [ --with-freetype-config=PROG Use FreeType configuration program PROG], freetype_config=$withval, freetype_config=auto)
+ AC_ARG_WITH(freetype-config,
+ AS_HELP_STRING([--with-freetype-config=PROG],
+ [Use FreeType configuration program PROG]),
+ [freetype_config=$withval], [freetype_config=auto])
if test "$freetype_config" = "auto" ; then
PKG_CHECK_MODULES(FREETYPE, freetype2,
AC_ARG_WITH(bzip2,
AS_HELP_STRING([--with-bzip2],
- [Support bzip2 compressed bitmap fonts]),
+ [Use libbz2 to support bzip2 compressed bitmap fonts (default: no)]),
[], [with_bzip2=no])
if test "x$with_bzip2" = xyes; then
AC_CHECK_LIB(bz2, BZ2_bzopen, [Z_LIBS="$Z_LIBS -lbz2"],
AM_CONDITIONAL(X_BZIP2_FONT_COMPRESSION, [test "x$with_bzip2" = xyes ])
AC_SUBST(Z_LIBS)
-AC_ARG_ENABLE(builtins, [ --disable-builtins ], [XFONT_BUILTINS=$enableval], [XFONT_BUILTINS=yes])
+AC_ARG_ENABLE(builtins,
+ AS_HELP_STRING([--disable-builtins],
+ [Support builtin fonts (default: enabled)]),
+ [XFONT_BUILTINS=$enableval], [XFONT_BUILTINS=yes])
AM_CONDITIONAL(XFONT_BUILTINS, [test "x$XFONT_BUILTINS" = xyes ])
if test "x$XFONT_BUILTINS" = xyes; then
AC_DEFINE(XFONT_BUILTINS,1,[Support built-in fonts])
XFONT_BITMAP=yes
fi
-AC_ARG_ENABLE(pcfformat, [ --disable-pcfformat ], [XFONT_PCFFORMAT=$enableval], [XFONT_PCFFORMAT=yes])
+AC_ARG_ENABLE(pcfformat,
+ AS_HELP_STRING([--disable-pcfformat],
+ [Support PCF format bitmap fonts (default: enabled)]),
+ [XFONT_PCFFORMAT=$enableval], [XFONT_PCFFORMAT=yes])
AM_CONDITIONAL(XFONT_PCFFORMAT, [test "x$XFONT_PCFFORMAT" = xyes])
if test "x$XFONT_PCFFORMAT" = xyes; then
AC_DEFINE(XFONT_PCFFORMAT,1,[Support pcf format bitmap font files])
XFONT_BITMAP=yes
fi
-AC_ARG_ENABLE(bdfformat, [ --disable-bdfformat ], [XFONT_BDFFORMAT=$enableval], [XFONT_BDFFORMAT=yes])
+AM_CONDITIONAL(XFONT_PCF_OR_BUILTIN,
+ [test "x$XFONT_PCFFORMAT" = xyes -o "x$XFONT_BUILTINS" = xyes])
+
+AC_ARG_ENABLE(bdfformat,
+ AS_HELP_STRING([--disable-bdfformat],
+ [Support BDF format bitmap fonts (default: enabled)]),
+ [XFONT_BDFFORMAT=$enableval], [XFONT_BDFFORMAT=yes])
AM_CONDITIONAL(XFONT_BDFFORMAT, [test "x$XFONT_BDFFORMAT" = xyes])
if test "x$XFONT_BDFFORMAT" = xyes; then
AC_DEFINE(XFONT_BDFFORMAT,1,[Support bdf format bitmap font files])
XFONT_BITMAP=yes
fi
-AC_ARG_ENABLE(snfformat, [ --disable-snfformat ], [XFONT_SNFFORMAT=$enableval], [XFONT_SNFFORMAT=yes])
+AC_ARG_ENABLE(snfformat,
+ AS_HELP_STRING([--enable-snfformat],
+ [Support SNF format bitmap fonts (default: disabled)]),
+ [XFONT_SNFFORMAT=$enableval], [XFONT_SNFFORMAT=no])
AM_CONDITIONAL(XFONT_SNFFORMAT, [test "x$XFONT_SNFFORMAT" = xyes])
if test "x$XFONT_SNFFORMAT" = xyes; then
AC_DEFINE(XFONT_SNFFORMAT,1,[Support snf format bitmap font files])
# Support connection to font servers?
#
-AC_ARG_ENABLE(fc, [ --disable-fc ],[XFONT_FC=$enableval],[XFONT_FC=yes])
+AC_ARG_ENABLE(fc,
+ AS_HELP_STRING([--disable-fc],
+ [Support connections to xfs servers (default: enabled)]),
+ [XFONT_FC=$enableval],[XFONT_FC=yes])
AM_CONDITIONAL(XFONT_FC, [test "x$XFONT_FC" = xyes])
if test "x$XFONT_FC" = xyes; then
AC_DEFINE(XFONT_FC,1,[Support the X Font Services Protocol])
AC_CHECK_LIB(m, hypot, [MATH_LIBS=-lm
AC_SUBST(MATH_LIBS)], AC_MSG_ERROR([*** libm is required]))
-PKG_CHECK_MODULES(XFONT, xproto xtrans fontsproto fontenc)
+PKG_CHECK_MODULES(XFONT, [xproto xtrans fontsproto >= 2.1.3 fontenc])
# Transport selection macro from xtrans.m4
XTRANS_CONNECTION_FLAGS
+++ /dev/null
-*.html
-*.ps
-*.pdf
-*.txt
+++ /dev/null
-# Add & Override for this directory and it's subdirectories
-fontconf.h
#define FontAliasFile "fonts.alias"
#define FontScalableFile "fonts.scale"
-extern int FontFileNameCheck ( char *name );
+extern int FontFileNameCheck ( const char *name );
extern int FontFileInitFPE ( FontPathElementPtr fpe );
extern int FontFileResetFPE ( FontPathElementPtr fpe );
extern int FontFileFreeFPE ( FontPathElementPtr fpe );
extern int FontFileOpenFont ( pointer client, FontPathElementPtr fpe,
- Mask flags, char *name, int namelen,
+ Mask flags, const char *name, int namelen,
fsBitmapFormat format, fsBitmapFormatMask fmask,
XID id, FontPtr *pFont, char **aliasName,
FontPtr non_cachable_font );
fsBitmapFormat format,
fsBitmapFormatMask fmask );
extern int FontFileListFonts ( pointer client, FontPathElementPtr fpe,
- char *pat, int len, int max,
+ const char *pat, int len, int max,
FontNamesPtr names );
extern int FontFileStartListFonts ( pointer client, FontPathElementPtr fpe,
- char *pat, int len, int max,
+ const char *pat, int len, int max,
pointer *privatep, int mark_aliases );
extern int FontFileStartListFontsWithInfo ( pointer client,
FontPathElementPtr fpe,
- char *pat, int len, int max,
+ const char *pat, int len, int max,
pointer *privatep );
extern int FontFileListNextFontWithInfo ( pointer client,
FontPathElementPtr fpe,
int *numFonts, pointer private );
extern int FontFileStartListFontsAndAliases ( pointer client,
FontPathElementPtr fpe,
- char *pat, int len, int max,
+ const char *pat, int len, int max,
pointer *privatep );
extern int FontFileListNextFontOrAlias ( pointer client,
FontPathElementPtr fpe,
fsBitmapFormatMask fmask,
Bool noSpecificSize );
-extern int FontFileReadDirectory ( char *directory, FontDirectoryPtr *pdir );
+extern int FontFileReadDirectory ( const char *directory, FontDirectoryPtr *pdir );
extern Bool FontFileDirectoryChanged ( FontDirectoryPtr dir );
#endif /* _FONTFILE_H_ */
extern void CopyISOLatin1Lowered(
char * /*dest*/,
- char * /*source*/,
+ const char * /*source*/,
int /*length*/
);
#endif
}
+#pragma GCC diagnostic ignored "-Wbad-function-cast"
+
int
FreeTypeRasteriseGlyph(unsigned idx, int flags, CharInfoPtr tgp,
FTInstancePtr instance, int hasMetrics)
i++;
info->props[i].name = MakeAtom("RASTERIZER_NAME", 15, TRUE);
- info->props[i].value = MakeAtom("FreeType", 10, TRUE);
+ info->props[i].value = MakeAtom("FreeType", 8, TRUE);
info->isStringProp[i] = 1;
i++;
int len = term-p-1;
char *value;
- len = term-p-1;
value=malloc(len+1);
memcpy(value, p+1, len);
value[len]='\0';
libXfont_la_SOURCES = dummy.c
-libXfont_la_LDFLAGS = -version-number 1:4:1
+libXfont_la_LDFLAGS = -version-number 1:4:1 -no-undefined
noinst_LTLIBRARIES = libbitmap.la
libbitmap_la_SOURCES = \
- bdfread.c \
- bdfutils.c \
bitmap.c \
bitmapfunc.c \
bitmaputil.c \
bitscale.c \
- fontink.c \
- pcfread.c \
- pcfwrite.c \
- snfread.c \
- snfstr.h
+ fontink.c
+
+if XFONT_BDFFORMAT
+libbitmap_la_SOURCES += bdfread.c bdfutils.c
+endif
+
+if XFONT_PCF_OR_BUILTIN
+libbitmap_la_SOURCES += pcfread.c
+endif
+
+if XFONT_PCFFORMAT
+libbitmap_la_SOURCES += pcfwrite.c
+endif
+
+if XFONT_SNFFORMAT
+libbitmap_la_SOURCES += snfread.c snfstr.h
+endif
case Linear8Bit:
case TwoD8Bit:
- if (pFont->info.firstRow > 0)
+ if (pFont->info.firstRow > 0) {
+ if (pDefault)
+ while (count--)
+ *glyphs++ = pDefault;
break;
+ }
if (pFont->info.allExist && pDefault) {
while (count--) {
c = (*chars++) - firstCol;
#include <config.h>
#endif
-/*
- * Translate monolithic #defines to modular definitions
- */
-
-#ifdef PCFFORMAT
-#define XFONT_PCFFORMAT 1
-#endif
-
-#ifdef SNFFORMAT
-#define XFONT_SNFFORMAT 1
-#endif
-
-#ifdef BDFFORMAT
-#define XFONT_BDFFORMAT 1
-#endif
-
#include <X11/fonts/fntfilst.h>
#include <X11/fonts/bitmap.h>
#include <X11/fonts/fontutil.h>
+#if XFONT_BDFFORMAT
#include <X11/fonts/bdfint.h>
+#endif
+#if XFONT_PCFFORMAT
#include <X11/fonts/pcf.h>
+#endif
+#if XFONT_SNFFORMAT
#include "snfstr.h"
+#endif
+#if XFONT_PCFFORMAT || XFONT_SNFFORMAT || XFONT_BDFFORMAT
typedef struct _BitmapFileFunctions {
int (*ReadFont) (FontPtr /* pFont */, FontFilePtr /* file */,
int /* bit */, int /* byte */,
{
return renderer - renderers;
}
+
+#else
+void
+BitmapRegisterFontFileFunctions (void)
+{
+ /* nothing to do */
+}
+#endif /* XFONT_PCFFORMAT || XFONT_SNFFORMAT || XFONT_BDFFORMAT */
#include <config.h>
#endif
-/*
- * Translate monolithic #defines to modular definitions
- */
-
-#ifdef PCFFORMAT
-#define XFONT_PCFFORMAT 1
-#endif
-
-#ifdef SNFFORMAT
-#define XFONT_SNFFORMAT 1
-#endif
-
-#ifdef BDFFORMAT
-#define XFONT_BDFFORMAT 1
-#endif
-
#include <X11/fonts/fntfilst.h>
#include <X11/fonts/bitmap.h>
#include <X11/fonts/fontutil.h>
#endif
/* Should get this from elsewhere */
-extern unsigned long serverGeneration;
+extern unsigned long __GetServerGeneration(void);
static void bitmapUnloadScalable (FontPtr pFont);
static void ScaleBitmap ( FontPtr pFont, CharInfoPtr opci,
char *isStringProp;
int nProps;
- if (bitscaleGeneration != serverGeneration) {
+ if (bitscaleGeneration != __GetServerGeneration()) {
initFontPropTable();
- bitscaleGeneration = serverGeneration;
+ bitscaleGeneration = __GetServerGeneration();
}
nProps = NPROPS + 1 + sizeof(fontPropTable) / sizeof(fontProp) +
sizeof(rawFontPropTable) / sizeof(fontProp);
* ScaleFont
* returns a pointer to the new scaled font, or NULL (due to AllocError).
*/
+#pragma GCC diagnostic ignored "-Wbad-function-cast"
+
static FontPtr
ScaleFont(FontPtr opf, /* originating font */
double widthMult, /* glyphs width scale factor */
needs to be for the output font */
if (vals->nranges)
{
- int i;
-
pfi->allExist = 0;
firstCol = 255;
lastCol = 0;
extern const BuiltinAliasRec builtin_alias[];
extern const int builtin_alias_count;
-extern FontFilePtr BuiltinFileOpen (char *);
+extern FontFilePtr BuiltinFileOpen (const char *);
extern int BuiltinFileClose (BufFilePtr, int);
-extern int BuiltinReadDirectory (char *, FontDirectoryPtr *);
+extern int BuiltinReadDirectory (const char *, FontDirectoryPtr *);
extern void BuiltinRegisterFontFileFunctions (void);
extern void BuiltinRegisterFpeFunctions (void);
}
int
-BuiltinReadDirectory (char *directory, FontDirectoryPtr *pdir)
+BuiltinReadDirectory (const char *directory, FontDirectoryPtr *pdir)
{
FontDirectoryPtr dir;
int i;
FontFilePtr
-BuiltinFileOpen (char *name)
+BuiltinFileOpen (const char *name)
{
int i;
BuiltinIOPtr io;
static const char builtin_fonts[] = "built-ins";
static int
-BuiltinNameCheck (char *name)
+BuiltinNameCheck (const char *name)
{
return (strcmp (name, builtin_fonts) == 0);
}
static int
BuiltinResetFPE (FontPathElementPtr fpe)
{
- FontDirectoryPtr dir;
-
- dir = (FontDirectoryPtr) fpe->private;
/* builtins can't change! */
return Successful;
}
for (i = 0; i < nprops; i++, dprop++, is_str++)
{
memcpy(&local_off, off_adr, SIZEOF(fsPropOffset));
+ if ((local_off.name.position >= pi->data_len) ||
+ (local_off.name.length >
+ (pi->data_len - local_off.name.position)))
+ goto bail;
dprop->name = MakeAtom(&pdc[local_off.name.position],
local_off.name.length, 1);
if (local_off.type != PropTypeString) {
dprop->value = local_off.value.position;
} else {
*is_str = TRUE;
+ if ((local_off.value.position >= pi->data_len) ||
+ (local_off.value.length >
+ (pi->data_len - local_off.value.position)))
+ goto bail;
dprop->value = (INT32) MakeAtom(&pdc[local_off.value.position],
local_off.value.length, 1);
if (dprop->value == BAD_RESOURCE)
{
+ bail:
free (pfi->props);
pfi->nprops = 0;
pfi->props = 0;
FontPtr
fs_create_font (FontPathElementPtr fpe,
- char *name,
+ const char *name,
int namelen,
fsBitmapFormat format,
fsBitmapFormatMask fmask)
FSGlyphPtr glyphs;
FSFontPtr fsfont = (FSFontPtr) pFont->fontPrivate;
- glyphs = malloc (sizeof (FSGlyphRec) + size);
+ if (size < (INT_MAX - sizeof (FSGlyphRec)))
+ glyphs = malloc (sizeof (FSGlyphRec) + size);
+ else
+ glyphs = NULL;
+ if (glyphs == NULL)
+ return NULL;
glyphs->next = fsfont->glyphs;
fsfont->glyphs = glyphs;
return (pointer) (glyphs + 1);
#include "fservestr.h"
#include <X11/fonts/fontutil.h>
#include <errno.h>
+#include <limits.h>
#include <time.h>
#define Time_t time_t
(pci)->descent || \
(pci)->characterWidth)
+/*
+ * SIZEOF(r) is in bytes, length fields in the protocol are in 32-bit words,
+ * so this converts for doing size comparisons.
+ */
+#define LENGTHOF(r) (SIZEOF(r) >> 2)
+
+/* Somewhat arbitrary limit on maximum reply size we'll try to read. */
+#define MAX_REPLY_LENGTH ((64 * 1024 * 1024) >> 2)
+
extern void ErrorF(const char *f, ...);
static int fs_read_glyphs ( FontPathElementPtr fpe, FSBlockDataPtr blockrec );
_fs_close_server (FSFpePtr conn);
static FSFpePtr
-_fs_init_conn (char *servername);
+_fs_init_conn (const char *servername);
static int
_fs_wait_connect (FSFpePtr conn);
rep->sequenceNumber,
conn->reqbuffer[i].opcode);
}
+
+#define _fs_reply_failed(rep, name, op) do { \
+ if (rep) { \
+ if (rep->type == FS_Error) \
+ fprintf (stderr, "Error: %d Request: %s\n", \
+ ((fsError *)rep)->request, #name); \
+ else \
+ fprintf (stderr, "Bad Length for %s Reply: %d %s %d\n", \
+ #name, rep->length, op, LENGTHOF(name)); \
+ } \
+} while (0)
+
#else
#define _fs_add_req_log(conn,op) ((conn)->current_seq++)
#define _fs_add_rep_log(conn,rep)
+#define _fs_reply_failed(rep,name,op)
#endif
static Bool
-fs_name_check(char *name)
+fs_name_check(const char *name)
{
/* Just make sure there is a protocol/ prefix */
return (name && *name != '/' && strchr(name, '/'));
fs_init_fpe(FontPathElementPtr fpe)
{
FSFpePtr conn;
- char *name;
+ const char *name;
int err;
int ret;
rep = (fsGenericReply *) buf;
+ /*
+ * Refuse to accept replies longer than a maximum reasonable length,
+ * before we pass to _fs_start_read, since it will try to resize the
+ * incoming connection buffer to this size. Also avoids integer overflow
+ * on 32-bit systems.
+ */
+ if (rep->length > MAX_REPLY_LENGTH)
+ {
+ ErrorF("fserve: reply length %d > MAX_REPLY_LENGTH, disconnecting"
+ " from font server\n", rep->length);
+ _fs_connection_died (conn);
+ *error = FSIO_ERROR;
+ return 0;
+ }
+
ret = _fs_start_read (conn, rep->length << 2, &buf);
if (ret != FSIO_READY)
{
int ret;
rep = (fsOpenBitmapFontReply *) fs_get_reply (conn, &ret);
- if (!rep || rep->type == FS_Error)
+ if (!rep || rep->type == FS_Error ||
+ (rep->length != LENGTHOF(fsOpenBitmapFontReply)))
{
if (ret == FSIO_BLOCK)
return StillWorking;
if (rep)
_fs_done_read (conn, rep->length << 2);
fs_cleanup_bfont (bfont);
+ _fs_reply_failed (rep, fsOpenBitmapFontReply, "!=");
return BadFontName;
}
FSFpePtr conn = (FSFpePtr) fpe->private;
fsQueryXInfoReply *rep;
char *buf;
+ long bufleft; /* length of reply left to use */
fsPropInfo *pi;
fsPropOffset *po;
pointer pd;
int ret;
rep = (fsQueryXInfoReply *) fs_get_reply (conn, &ret);
- if (!rep || rep->type == FS_Error)
+ if (!rep || rep->type == FS_Error ||
+ (rep->length < LENGTHOF(fsQueryXInfoReply)))
{
if (ret == FSIO_BLOCK)
return StillWorking;
if (rep)
_fs_done_read (conn, rep->length << 2);
fs_cleanup_bfont (bfont);
+ _fs_reply_failed (rep, fsQueryXInfoReply, "<");
return BadFontName;
}
buf = (char *) rep;
buf += SIZEOF(fsQueryXInfoReply);
+ bufleft = rep->length << 2;
+ bufleft -= SIZEOF(fsQueryXInfoReply);
+
/* move the data over */
fsUnpack_XFontInfoHeader(rep, pInfo);
_fs_init_fontinfo(conn, pInfo);
/* Compute offsets into the reply */
+ if (bufleft < SIZEOF(fsPropInfo))
+ {
+ ret = -1;
+#ifdef DEBUG
+ fprintf(stderr, "fsQueryXInfo: bufleft (%ld) < SIZEOF(fsPropInfo)\n",
+ bufleft);
+#endif
+ goto bail;
+ }
pi = (fsPropInfo *) buf;
buf += SIZEOF (fsPropInfo);
+ bufleft -= SIZEOF(fsPropInfo);
+ if ((bufleft / SIZEOF(fsPropOffset)) < pi->num_offsets)
+ {
+ ret = -1;
+#ifdef DEBUG
+ fprintf(stderr,
+ "fsQueryXInfo: bufleft (%ld) / SIZEOF(fsPropOffset) < %d\n",
+ bufleft, pi->num_offsets);
+#endif
+ goto bail;
+ }
po = (fsPropOffset *) buf;
buf += pi->num_offsets * SIZEOF(fsPropOffset);
+ bufleft -= pi->num_offsets * SIZEOF(fsPropOffset);
+ if (bufleft < pi->data_len)
+ {
+ ret = -1;
+#ifdef DEBUG
+ fprintf(stderr,
+ "fsQueryXInfo: bufleft (%ld) < data_len (%d)\n",
+ bufleft, pi->data_len);
+#endif
+ goto bail;
+ }
pd = (pointer) buf;
buf += pi->data_len;
+ bufleft -= pi->data_len;
/* convert the properties and step over the reply */
ret = _fs_convert_props(pi, po, pd, pInfo);
+ bail:
_fs_done_read (conn, rep->length << 2);
if (ret == -1)
FontInfoRec *fi = &bfont->pfont->info;
rep = (fsQueryXExtents16Reply *) fs_get_reply (conn, &ret);
- if (!rep || rep->type == FS_Error)
+ if (!rep || rep->type == FS_Error ||
+ (rep->length < LENGTHOF(fsQueryXExtents16Reply)))
{
if (ret == FSIO_BLOCK)
return StillWorking;
if (rep)
_fs_done_read (conn, rep->length << 2);
fs_cleanup_bfont (bfont);
+ _fs_reply_failed (rep, fsQueryXExtents16Reply, "<");
return BadFontName;
}
numInfos *= 2;
haveInk = TRUE;
}
- ci = pCI = malloc(sizeof(CharInfoRec) * numInfos);
+ if (numInfos >= (INT_MAX / sizeof(CharInfoRec))) {
+#ifdef DEBUG
+ fprintf(stderr,
+ "fsQueryXExtents16: numInfos (%d) >= %ld\n",
+ numInfos, (INT_MAX / sizeof(CharInfoRec)));
+#endif
+ pCI = NULL;
+ }
+ else if (numExtents > ((rep->length - LENGTHOF(fsQueryXExtents16Reply))
+ / LENGTHOF(fsXCharInfo))) {
+#ifdef DEBUG
+ fprintf(stderr,
+ "fsQueryXExtents16: numExtents (%d) > (%d - %d) / %d\n",
+ numExtents, rep->length,
+ LENGTHOF(fsQueryXExtents16Reply), LENGTHOF(fsXCharInfo));
+#endif
+ pCI = NULL;
+ }
+ else
+ pCI = malloc(sizeof(CharInfoRec) * numInfos);
if (!pCI)
{
}
#ifdef DEBUG
-static char *fs_open_states[] = {
+static const char *fs_open_states[] = {
"OPEN_REPLY ",
"INFO_REPLY ",
"EXTENT_REPLY",
{
FSBlockDataPtr blockrec;
FSBlockedFontPtr bfont;
- FSBlockedListPtr blist;
static CARD32 lastState;
static FSBlockDataPtr lastBlock;
"<freed>");
break;
case FS_LIST_FONTS:
- blist = (FSBlockedListPtr) blockrec->data;
fprintf (stderr, " Blocked list errcode %d sequence %d\n",
blockrec->errcode, blockrec->sequenceNumber);
break;
/* ARGSUSED */
static int
fs_send_open_font(pointer client, FontPathElementPtr fpe, Mask flags,
- char *name, int namelen,
+ const char *name, int namelen,
fsBitmapFormat format, fsBitmapFormatMask fmask,
XID id, FontPtr *ppfont)
{
if (conn->blockState & FS_GIVE_UP)
return BadFontName;
- if (namelen <= 0 || namelen > sizeof (buf) - 1)
+ if (namelen < 0 || namelen > sizeof (buf) - 1)
return BadFontName;
/*
/* ARGSUSED */
static int
fs_open_font(pointer client, FontPathElementPtr fpe, Mask flags,
- char *name, int namelen,
+ const char *name, int namelen,
fsBitmapFormat format, fsBitmapFormatMask fmask,
XID id, FontPtr *ppfont,
char **alias, FontPtr non_cachable_font)
FontInfoPtr pfi = &pfont->info;
fsQueryXBitmaps16Reply *rep;
char *buf;
+ long bufleft; /* length of reply left to use */
fsOffset32 *ppbits;
fsOffset32 local_off;
char *off_adr;
unsigned long minchar, maxchar;
rep = (fsQueryXBitmaps16Reply *) fs_get_reply (conn, &ret);
- if (!rep || rep->type == FS_Error)
+ if (!rep || rep->type == FS_Error ||
+ (rep->length < LENGTHOF(fsQueryXBitmaps16Reply)))
{
if (ret == FSIO_BLOCK)
return StillWorking;
if (rep)
_fs_done_read (conn, rep->length << 2);
err = AllocError;
+ _fs_reply_failed (rep, fsQueryXBitmaps16Reply, "<");
goto bail;
}
buf = (char *) rep;
buf += SIZEOF (fsQueryXBitmaps16Reply);
+ bufleft = rep->length << 2;
+ bufleft -= SIZEOF (fsQueryXBitmaps16Reply);
+
+ if ((bufleft / SIZEOF (fsOffset32)) < rep->num_chars)
+ {
+#ifdef DEBUG
+ fprintf(stderr,
+ "fsQueryXBitmaps16: num_chars (%d) > bufleft (%ld) / %d\n",
+ rep->num_chars, bufleft, SIZEOF (fsOffset32));
+#endif
+ err = AllocError;
+ goto bail;
+ }
ppbits = (fsOffset32 *) buf;
buf += SIZEOF (fsOffset32) * (rep->num_chars);
+ bufleft -= SIZEOF (fsOffset32) * (rep->num_chars);
+ if (bufleft < rep->nbytes)
+ {
+#ifdef DEBUG
+ fprintf(stderr,
+ "fsQueryXBitmaps16: nbytes (%d) > bufleft (%ld)\n",
+ rep->nbytes, bufleft);
+#endif
+ err = AllocError;
+ goto bail;
+ }
pbitmaps = (pointer ) buf;
if (blockrec->type == FS_LOAD_GLYPHS)
*/
if (NONZEROMETRICS(&fsdata->encoding[minchar].metrics))
{
- if (local_off.length)
+ if (local_off.length &&
+ (local_off.position < rep->nbytes) &&
+ (local_off.length <= (rep->nbytes - local_off.position)))
{
bits = allbits;
allbits += local_off.length;
}
-extern pointer serverClient; /* This could be any number that
+extern pointer __GetServerClient(void); /* This could be any number that
doesn't conflict with existing
client values. */
* perform an unpleasant job that, we hope, will never be required.
*/
- while ((err = _fs_load_glyphs(serverClient, pfont, TRUE, 0, 0, NULL)) ==
+ while ((err = _fs_load_glyphs(__GetServerClient(), pfont, TRUE, 0, 0, NULL)) ==
Suspended)
{
if (fs_await_reply (conn) != FSIO_READY)
{
/* Get rid of blockrec */
- fs_client_died(serverClient, pfont->fpe);
+ fs_client_died(__GetServerClient(), pfont->fpe);
err = BadCharRange;
break;
}
- fs_read_reply (pfont->fpe, serverClient);
+ fs_read_reply (pfont->fpe, __GetServerClient());
}
return err;
}
FSBlockedListPtr blist = (FSBlockedListPtr) blockrec->data;
fsListFontsReply *rep;
char *data;
+ long dataleft; /* length of reply left to use */
int length,
i,
ret;
int err;
rep = (fsListFontsReply *) fs_get_reply (conn, &ret);
- if (!rep || rep->type == FS_Error)
+ if (!rep || rep->type == FS_Error ||
+ (rep->length < LENGTHOF(fsListFontsReply)))
{
if (ret == FSIO_BLOCK)
return StillWorking;
if (rep)
_fs_done_read (conn, rep->length << 2);
+ _fs_reply_failed (rep, fsListFontsReply, "<");
return AllocError;
}
data = (char *) rep + SIZEOF (fsListFontsReply);
+ dataleft = (rep->length << 2) - SIZEOF (fsListFontsReply);
err = Successful;
/* copy data into FontPathRecord */
for (i = 0; i < rep->nFonts; i++)
{
+ if (dataleft < 1)
+ break;
length = *(unsigned char *)data++;
+ dataleft--; /* used length byte */
+ if (length > dataleft) {
+#ifdef DEBUG
+ fprintf(stderr,
+ "fsListFonts: name length (%d) > dataleft (%ld)\n",
+ length, dataleft);
+#endif
+ err = BadFontName;
+ break;
+ }
err = AddFontNamesName(blist->names, data, length);
if (err != Successful)
break;
data += length;
+ dataleft -= length;
}
_fs_done_read (conn, rep->length << 2);
return err;
}
static int
-fs_send_list_fonts(pointer client, FontPathElementPtr fpe, char *pattern,
+fs_send_list_fonts(pointer client, FontPathElementPtr fpe, const char *pattern,
int patlen, int maxnames, FontNamesPtr newnames)
{
FSFpePtr conn = (FSFpePtr) fpe->private;
static int
fs_list_fonts(pointer client, FontPathElementPtr fpe,
- char *pattern, int patlen, int maxnames, FontNamesPtr newnames)
+ const char *pattern, int patlen, int maxnames, FontNamesPtr newnames)
{
FSFpePtr conn = (FSFpePtr) fpe->private;
FSBlockDataPtr blockrec;
FSBlockedListInfoPtr binfo = (FSBlockedListInfoPtr) blockrec->data;
fsListFontsWithXInfoReply *rep;
char *buf;
+ long bufleft;
FSFpePtr conn = (FSFpePtr) fpe->private;
fsPropInfo *pi;
fsPropOffset *po;
_fs_free_props (&binfo->info);
rep = (fsListFontsWithXInfoReply *) fs_get_reply (conn, &ret);
- if (!rep || rep->type == FS_Error)
+ if (!rep || rep->type == FS_Error ||
+ ((rep->nameLength != 0) &&
+ (rep->length < LENGTHOF(fsListFontsWithXInfoReply))))
{
if (ret == FSIO_BLOCK)
return StillWorking;
binfo->status = FS_LFWI_FINISHED;
err = AllocError;
+ _fs_reply_failed (rep, fsListFontsWithXInfoReply, "<");
goto done;
}
/*
}
buf = (char *) rep + SIZEOF (fsListFontsWithXInfoReply);
+ bufleft = (rep->length << 2) - SIZEOF (fsListFontsWithXInfoReply);
/*
* The original FS implementation didn't match
*/
if (conn->fsMajorVersion <= 1)
{
+ if (rep->nameLength > bufleft) {
+#ifdef DEBUG
+ fprintf(stderr,
+ "fsListFontsWithXInfo: name length (%d) > bufleft (%ld)\n",
+ (int) rep->nameLength, bufleft);
+#endif
+ err = AllocError;
+ goto done;
+ }
+ /* binfo->name is a 256 char array, rep->nameLength is a CARD8 */
memcpy (binfo->name, buf, rep->nameLength);
buf += _fs_pad_length (rep->nameLength);
+ bufleft -= _fs_pad_length (rep->nameLength);
}
pi = (fsPropInfo *) buf;
+ if (SIZEOF (fsPropInfo) > bufleft) {
+#ifdef DEBUG
+ fprintf(stderr,
+ "fsListFontsWithXInfo: PropInfo length (%d) > bufleft (%ld)\n",
+ (int) SIZEOF (fsPropInfo), bufleft);
+#endif
+ err = AllocError;
+ goto done;
+ }
+ bufleft -= SIZEOF (fsPropInfo);
buf += SIZEOF (fsPropInfo);
po = (fsPropOffset *) buf;
+ if (pi->num_offsets > (bufleft / SIZEOF (fsPropOffset))) {
+#ifdef DEBUG
+ fprintf(stderr,
+ "fsListFontsWithXInfo: offset length (%d * %d) > bufleft (%ld)\n",
+ pi->num_offsets, (int) SIZEOF (fsPropOffset), bufleft);
+#endif
+ err = AllocError;
+ goto done;
+ }
+ bufleft -= pi->num_offsets * SIZEOF (fsPropOffset);
buf += pi->num_offsets * SIZEOF (fsPropOffset);
pd = (pointer) buf;
+ if (pi->data_len > bufleft) {
+#ifdef DEBUG
+ fprintf(stderr,
+ "fsListFontsWithXInfo: data length (%d) > bufleft (%ld)\n",
+ pi->data_len, bufleft);
+#endif
+ err = AllocError;
+ goto done;
+ }
+ bufleft -= pi->data_len;
buf += pi->data_len;
if (conn->fsMajorVersion > 1)
{
+ if (rep->nameLength > bufleft) {
+#ifdef DEBUG
+ fprintf(stderr,
+ "fsListFontsWithXInfo: name length (%d) > bufleft (%ld)\n",
+ (int) rep->nameLength, bufleft);
+#endif
+ err = AllocError;
+ goto done;
+ }
+ /* binfo->name is a 256 char array, rep->nameLength is a CARD8 */
memcpy (binfo->name, buf, rep->nameLength);
buf += _fs_pad_length (rep->nameLength);
+ bufleft -= _fs_pad_length (rep->nameLength);
}
#ifdef DEBUG
/* ARGSUSED */
static int
fs_start_list_with_info(pointer client, FontPathElementPtr fpe,
- char *pattern, int len, int maxnames, pointer *pdata)
+ const char *pattern, int len, int maxnames, pointer *pdata)
{
FSFpePtr conn = (FSFpePtr) fpe->private;
FSBlockDataPtr blockrec;
int ret = FSIO_ERROR;
fsConnSetup *setup;
FSFpeAltPtr alts;
- int i, alt_len;
+ unsigned int i, alt_len;
int setup_len;
char *alt_save, *alt_names;
}
if (setup->num_alternates)
{
+ size_t alt_name_len = setup->alternate_len << 2;
alts = malloc (setup->num_alternates * sizeof (FSFpeAltRec) +
- (setup->alternate_len << 2));
+ alt_name_len);
if (alts)
{
alt_names = (char *) (setup + 1);
{
alts[i].subset = alt_names[0];
alt_len = alt_names[1];
+ if (alt_len >= alt_name_len) {
+ /*
+ * Length is longer than setup->alternate_len
+ * told us to allocate room for, assume entire
+ * alternate list is corrupted.
+ */
+#ifdef DEBUG
+ fprintf (stderr,
+ "invalid alt list (length %lx >= %lx)\n",
+ (long) alt_len, (long) alt_name_len);
+#endif
+ free(alts);
+ return FSIO_ERROR;
+ }
alts[i].name = alt_save;
memcpy (alt_save, alt_names + 2, alt_len);
alt_save[alt_len] = '\0';
alt_save += alt_len + 1;
+ alt_name_len -= alt_len + 1;
alt_names += _fs_pad_length (alt_len + 2);
}
conn->numAlts = setup->num_alternates;
* by a bogus catalogue
*/
lcreq.reqType = FS_ListCatalogues;
+ lcreq.data = 0;
lcreq.length = (SIZEOF(fsListCataloguesReq)) >> 2;
lcreq.maxNames = 0;
lcreq.nbytes = 0;
static FSFpePtr
-_fs_init_conn (char *servername)
+_fs_init_conn (const char *servername)
{
FSFpePtr conn;
extern void _fs_convert_char_info ( fsXCharInfo *src, xCharInfo *dst );
extern void _fs_free_props (FontInfoPtr pfi);
extern FontPtr fs_create_font (FontPathElementPtr fpe,
- char *name,
+ const char *name,
int namelen,
fsBitmapFormat format,
fsBitmapFormatMask fmask);
#ifndef _FSIO_H_
#define _FSIO_H_
-#undef DEBUG
+#ifdef DEBUG
#define REQUEST_LOG_SIZE 100
+#endif
typedef struct _fs_fpe_alternate {
char *name;
setmode(fd,O_BINARY);
#endif
f = BufFileCreate ((char *)(long) fd, 0, BufFileRawFlush, 0, BufFileFlush);
- f->bufp = f->buffer;
- f->left = BUFFILESIZE;
+ if (f != NULL) {
+ f->bufp = f->buffer;
+ f->left = BUFFILESIZE;
+ }
return f;
}
static int CatalogueFreeFPE (FontPathElementPtr fpe);
static int
-CatalogueNameCheck (char *name)
+CatalogueNameCheck (const char *name)
{
return strncmp(name, CataloguePrefix, sizeof(CataloguePrefix) - 1) == 0;
}
if (subfpe->refcount == 0)
{
FontFileFreeFPE (subfpe);
- free(subfpe->name);
+ free((void *) subfpe->name);
free(subfpe);
}
}
CatalogueUnrefFPEs (fpe);
while (entry = readdir(dir), entry != NULL)
{
+ char *name;
snprintf(link, sizeof link, "%s/%s", path, entry->d_name);
len = readlink(link, dest, sizeof dest - 1);
if (len < 0)
* (which uses font->fpe->type) goes to CatalogueCloseFont. */
subfpe->type = fpe->type;
subfpe->name_length = len;
- subfpe->name = malloc (len + 1);
- if (subfpe->name == NULL)
+ name = malloc (len + 1);
+ if (name == NULL)
{
free(subfpe);
continue;
}
- memcpy(subfpe->name, dest, len);
- subfpe->name[len] = '\0';
+ memcpy(name, dest, len);
+ name[len] = '\0';
+ subfpe->name = name;
/* The X server will manipulate the subfpe ref counts
* associated with the font in OpenFont and CloseFont, so we
if (FontFileInitFPE (subfpe) != Successful)
{
- free(subfpe->name);
+ free((void *) subfpe->name);
free(subfpe);
continue;
}
static int
CatalogueOpenFont (pointer client, FontPathElementPtr fpe, Mask flags,
- char *name, int namelen,
+ const char *name, int namelen,
fsBitmapFormat format, fsBitmapFormatMask fmask,
XID id, FontPtr *pFont, char **aliasName,
FontPtr non_cachable_font)
{
CataloguePtr cat = fpe->private;
FontPathElementPtr subfpe;
- FontDirectoryPtr dir;
int i, status;
CatalogueRescan (fpe, FALSE);
for (i = 0; i < cat->fpeCount; i++)
{
subfpe = cat->fpeList[i];
- dir = subfpe->private;
status = FontFileOpenFont(client, subfpe, flags,
name, namelen, format, fmask, id,
pFont, aliasName, non_cachable_font);
}
static int
-CatalogueListFonts (pointer client, FontPathElementPtr fpe, char *pat,
+CatalogueListFonts (pointer client, FontPathElementPtr fpe, const char *pat,
int len, int max, FontNamesPtr names)
{
CataloguePtr cat = fpe->private;
FontPathElementPtr subfpe;
- FontDirectoryPtr dir;
int i;
CatalogueRescan (fpe, FALSE);
for (i = 0; i < cat->fpeCount; i++)
{
subfpe = cat->fpeList[i];
- dir = subfpe->private;
FontFileListFonts(client, subfpe, pat, len, max, names);
}
return Successful;
}
-int
-FontFileStartListFonts(pointer client, FontPathElementPtr fpe,
- char *pat, int len, int max,
- pointer *privatep, int mark_aliases);
-
typedef struct _LFWIData {
pointer *privates;
int current;
static int
CatalogueStartListFonts(pointer client, FontPathElementPtr fpe,
- char *pat, int len, int max, pointer *privatep,
+ const char *pat, int len, int max, pointer *privatep,
int mark_aliases)
{
CataloguePtr cat = fpe->private;
static int
CatalogueStartListFontsWithInfo(pointer client, FontPathElementPtr fpe,
- char *pat, int len, int max,
+ const char *pat, int len, int max,
pointer *privatep)
{
return CatalogueStartListFonts(client, fpe, pat, len, max, privatep, 0);
static int
CatalogueStartListFontsAndAliases(pointer client, FontPathElementPtr fpe,
- char *pat, int len, int max,
+ const char *pat, int len, int max,
pointer *privatep)
{
return CatalogueStartListFonts(client, fpe, pat, len, max, privatep, 1);
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
+#include <limits.h>
static Bool AddFileNameAliases ( FontDirectoryPtr dir );
static int ReadFontAlias ( char *directory, Bool isFile,
static int lexAlias ( FILE *file, char **lexToken );
static int lexc ( FILE *file );
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
int
-FontFileReadDirectory (char *directory, FontDirectoryPtr *pdir)
+FontFileReadDirectory (const char *directory, FontDirectoryPtr *pdir)
{
char file_name[MAXFONTFILENAMELEN];
char font_name[MAXFONTNAMELEN];
int nsize;
char *nbuf;
+ if (tokenSize >= (INT_MAX >> 2))
+ /* Stop before we overflow */
+ return EALLOC;
nsize = tokenSize ? (tokenSize << 1) : 64;
nbuf = realloc(tokenBuf, nsize);
if (!nbuf)
if (table->sorted)
return (FontEntryPtr) 0; /* "cannot" happen */
if (table->used == table->size) {
+ if (table->size >= ((INT32_MAX / sizeof(FontEntryRec)) - 100))
+ /* If we've read so many entries we're going to ask for 2gb
+ or more of memory, something is so wrong with this font
+ directory that we should just give up before we overflow. */
+ return NULL;
newsize = table->size + 100;
entry = realloc(table->entries, newsize * sizeof(FontEntryRec));
if (!entry)
}
_X_HIDDEN void
-CopyISOLatin1Lowered(char *dest, char *source, int length)
+CopyISOLatin1Lowered(char *dest, const char *source, int length)
{
int i;
for (i = 0; i < length; i++, source++, dest++)
FontPtr non_cachable_font);
int
-FontFileNameCheck (char *name)
+FontFileNameCheck (const char *name)
{
#ifndef NCD
#if defined(WIN32)
/* ARGSUSED */
int
FontFileOpenFont (pointer client, FontPathElementPtr fpe, Mask flags,
- char *name, int namelen,
+ const char *name, int namelen,
fsBitmapFormat format, fsBitmapFormatMask fmask,
XID id, FontPtr *pFont, char **aliasName,
FontPtr non_cachable_font)
/* ARGSUSED */
static int
_FontFileListFonts (pointer client, FontPathElementPtr fpe,
- char *pat, int len, int max, FontNamesPtr names,
+ const char *pat, int len, int max, FontNamesPtr names,
int mark_aliases)
{
FontDirectoryPtr dir;
} LFWIDataRec, *LFWIDataPtr;
int
-FontFileListFonts (pointer client, FontPathElementPtr fpe, char *pat,
+FontFileListFonts (pointer client, FontPathElementPtr fpe, const char *pat,
int len, int max, FontNamesPtr names)
{
return _FontFileListFonts (client, fpe, pat, len, max, names, 0);
int
FontFileStartListFonts(pointer client, FontPathElementPtr fpe,
- char *pat, int len, int max,
+ const char *pat, int len, int max,
pointer *privatep, int mark_aliases)
{
LFWIDataPtr data;
int
FontFileStartListFontsWithInfo(pointer client, FontPathElementPtr fpe,
- char *pat, int len, int max,
+ const char *pat, int len, int max,
pointer *privatep)
{
return FontFileStartListFonts(client, fpe, pat, len, max, privatep, 0);
int
FontFileStartListFontsAndAliases(pointer client, FontPathElementPtr fpe,
- char *pat, int len, int max,
+ const char *pat, int len, int max,
pointer *privatep)
{
return FontFileStartListFonts(client, fpe, pat, len, max, privatep, 1);
* XXX Maybe should allow unregistering renders. For now, just clear the
* list at each new generation.
*/
-extern unsigned long serverGeneration;
+extern unsigned long __GetServerGeneration(void);
static unsigned long rendererGeneration = 0;
Bool
int i;
struct _FontRenderersElement *new;
- if (rendererGeneration != serverGeneration) {
- rendererGeneration = serverGeneration;
+ if (rendererGeneration != __GetServerGeneration()) {
+ rendererGeneration = __GetServerGeneration();
renderers.number = 0;
if (renderers.renderers)
free(renderers.renderers);
csignal.c \
delfntcid.c \
errorf.c \
- fatalerror.c \
findoldfnt.c \
getcres.c \
getdefptsize.c \
servclient.c \
setfntauth.c \
stfntcfnt.c \
+ stubsinit.c \
stubs.h
weak int
client_auth_generation(ClientPtr client)
{
+ OVERRIDE_SYMBOL(client_auth_generation, client);
return 0;
}
weak Bool
ClientSignal(ClientPtr client)
{
+ OVERRIDE_SYMBOL(ClientSignal,client);
return True;
}
weak void
DeleteFontClientID(Font id)
{
+ OVERRIDE_SYMBOL(DeleteFontClientID, id);
}
weak void
ErrorF(const char *f, ...)
{
+ OVERRIDE_VA_SYMBOL(VErrorF, f);
}
+++ /dev/null
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "stubs.h"
-
-#ifdef __SUNPRO_C
-#pragma weak FatalError
-#endif
-
-weak void
-FatalError(const char *f, ...)
-{
-}
weak FontPtr
find_old_font(FSID id)
{
+ OVERRIDE_SYMBOL(find_old_font, id);
return (FontPtr)NULL;
}
weak FontResolutionPtr
GetClientResolutions(int *num)
{
+ OVERRIDE_SYMBOL(GetClientResolutions, num);
return (FontResolutionPtr) 0;
}
weak int
GetDefaultPointSize(void)
{
+ OVERRIDE_SYMBOL(GetDefaultPointSize);
return 0;
}
weak Font
GetNewFontClientID(void)
{
+ OVERRIDE_SYMBOL(GetNewFontClientID);
return (Font)0;
}
weak unsigned long
GetTimeInMillis (void)
{
+ OVERRIDE_SYMBOL(GetTimeInMillis);
return 0;
}
init_fs_handlers(FontPathElementPtr fpe,
BlockHandlerProcPtr block_handler)
{
+ OVERRIDE_SYMBOL(init_fs_handlers, fpe, block_handler);
return Successful;
}
NextLaFunc next_list_alias_func,
SetPathFunc set_path_func)
{
+ OVERRIDE_SYMBOL(RegisterFPEFunctions, name_func, init_func, free_func,
+ reset_func, open_func, close_func, list_func, start_lfwi_func,
+ next_lfwi_func, wakeup_func, client_died, load_glyphs,
+ start_list_alias_func, next_list_alias_func, set_path_func);
return 0;
}
BlockHandlerProcPtr blockHandler,
Bool all)
{
+ OVERRIDE_SYMBOL(remove_fs_handlers, fpe, blockHandler, all);
}
#endif
weak void *serverClient = 0;
+
+void *__GetServerClient(void);
+
+void *
+__GetServerClient(void)
+{
+ OVERRIDE_DATA(serverClient);
+ return serverClient;
+}
weak int
set_font_authorizations(char **authorizations, int *authlen, ClientPtr client)
{
+ OVERRIDE_SYMBOL(set_font_authorizations, authorizations, authlen, client);
return 0;
}
weak int
StoreFontClientFont(FontPtr pfont, Font id)
{
+ OVERRIDE_SYMBOL(StoreFontClientFont, pfont, id);
return 0;
}
#endif
#endif
+#if defined(NO_WEAK_SYMBOLS) && defined(PIC)
+#include <stdarg.h>
+extern int _font_init_stubs(void);
+#define OVERRIDE_DATA(sym) \
+ _font_init_stubs(); \
+ if (__ptr_##sym && __ptr_##sym != &sym) \
+ sym = *__ptr_##sym
+#define OVERRIDE_SYMBOL(sym,...) \
+ _font_init_stubs(); \
+ if (__##sym && __##sym != sym) \
+ return (*__##sym)(__VA_ARGS__)
+#define OVERRIDE_VA_SYMBOL(sym,f) \
+ va_list _args; \
+ _font_init_stubs(); \
+ va_start(_args, f); \
+ if (__##sym) \
+ (*__##sym)(f, _args); \
+ va_end(_args)
+
+int (*__client_auth_generation)(ClientPtr);
+Bool (*__ClientSignal)(ClientPtr);
+void (*__DeleteFontClientID)(Font);
+void (*__VErrorF)(const char *, va_list);
+FontPtr (*__find_old_font)(FSID);
+FontResolutionPtr (*__GetClientResolutions)(int *);
+int (*__GetDefaultPointSize)(void);
+Font (*__GetNewFontClientID)(void);
+unsigned long (*__GetTimeInMillis)(void);
+int (*__init_fs_handlers)(FontPathElementPtr, BlockHandlerProcPtr);
+int (*__RegisterFPEFunctions)(NameCheckFunc, InitFpeFunc, FreeFpeFunc,
+ ResetFpeFunc, OpenFontFunc, CloseFontFunc, ListFontsFunc,
+ StartLfwiFunc, NextLfwiFunc, WakeupFpeFunc, ClientDiedFunc,
+ LoadGlyphsFunc, StartLaFunc, NextLaFunc, SetPathFunc);
+void (*__remove_fs_handlers)(FontPathElementPtr, BlockHandlerProcPtr, Bool);
+void **__ptr_serverClient;
+int (*__set_font_authorizations)(char **, int *, ClientPtr);
+int (*__StoreFontClientFont)(FontPtr, Font);
+Atom (*__MakeAtom)(const char *, unsigned, int);
+int (*__ValidAtom)(Atom);
+char *(*__NameForAtom)(Atom);
+unsigned long *__ptr_serverGeneration;
+void (*__register_fpe_functions)(void);
+#else /* NO_WEAK_SYMBOLS && PIC */
+#define OVERRIDE_DATA(sym)
+#define OVERRIDE_SYMBOL(sym,...)
+#define OVERRIDE_VA_SYMBOL(sym,f)
+#endif
+
/* This is really just a hack for now... __APPLE__ really should be using
* the weak symbols route above, but it's causing an as-yet unresolved issue,
* so we're instead building with flat_namespace.
extern unsigned long GetTimeInMillis (void);
extern void ErrorF(const char *format, ...);
-extern void FatalError(const char *format, ...);
/* end of file */
--- /dev/null
+#include "stubs.h"
+
+#if defined(NO_WEAK_SYMBOLS) && defined(PIC)
+
+#ifdef WIN32
+#include <X11/Xwindows.h>
+#define DLOPEN_SELF() GetModuleHandle(NULL)
+#define DLSYM(h,f) GetProcAddress(h,f)
+#else
+#include <dlfcn.h>
+#define DLOPEN_SELF() dlopen(NULL, RTLD_LOCAL)
+#define DLSYM(h,f) dlsym(h, f)
+#endif
+
+int (*__client_auth_generation)(ClientPtr) = NULL;
+Bool (*__ClientSignal)(ClientPtr) = NULL;
+void (*__DeleteFontClientID)(Font) = NULL;
+void (*__VErrorF)(const char *, va_list) = NULL;
+FontPtr (*__find_old_font)(FSID) = NULL;
+FontResolutionPtr (*__GetClientResolutions)(int *) = NULL;
+int (*__GetDefaultPointSize)(void) = NULL;
+Font (*__GetNewFontClientID)(void) = NULL;
+unsigned long (*__GetTimeInMillis)(void) = NULL;
+int (*__init_fs_handlers)(FontPathElementPtr, BlockHandlerProcPtr) = NULL;
+int (*__RegisterFPEFunctions)(NameCheckFunc, InitFpeFunc, FreeFpeFunc,
+ ResetFpeFunc, OpenFontFunc, CloseFontFunc, ListFontsFunc,
+ StartLfwiFunc, NextLfwiFunc, WakeupFpeFunc, ClientDiedFunc,
+ LoadGlyphsFunc, StartLaFunc, NextLaFunc, SetPathFunc) = NULL;
+void (*__remove_fs_handlers)(FontPathElementPtr, BlockHandlerProcPtr, Bool) = NULL;
+void **__ptr_serverClient = NULL;
+int (*__set_font_authorizations)(char **, int *, ClientPtr) = NULL;
+int (*__StoreFontClientFont)(FontPtr, Font) = NULL;
+Atom (*__MakeAtom)(const char *, unsigned, int) = NULL;
+int (*__ValidAtom)(Atom) = NULL;
+char *(*__NameForAtom)(Atom) = NULL;
+unsigned long *__ptr_serverGeneration = NULL;
+void (*__register_fpe_functions)(void) = NULL;
+
+#define INIT_SYMBOL(sym) \
+ if (!__##sym) \
+ __##sym = (typeof(__##sym)) DLSYM(handle, #sym)
+#define INIT_DATA(sym) \
+ if (!__ptr_##sym) \
+ __ptr_##sym = (typeof(__ptr_##sym)) DLSYM(handle, #sym)
+
+int
+_font_init_stubs (void)
+{
+ static int inited = FALSE;
+ static void *handle = NULL;
+
+ if (inited)
+ return inited;
+ if (!handle)
+ handle = DLOPEN_SELF();
+
+ INIT_SYMBOL(client_auth_generation);
+ INIT_SYMBOL(ClientSignal);
+ INIT_SYMBOL(DeleteFontClientID);
+ INIT_SYMBOL(VErrorF);
+ INIT_SYMBOL(find_old_font);
+ INIT_SYMBOL(GetClientResolutions);
+ INIT_SYMBOL(GetDefaultPointSize);
+ INIT_SYMBOL(GetNewFontClientID);
+ INIT_SYMBOL(GetTimeInMillis);
+ INIT_SYMBOL(init_fs_handlers);
+ INIT_SYMBOL(RegisterFPEFunctions);
+ INIT_SYMBOL(remove_fs_handlers);
+ INIT_SYMBOL(set_font_authorizations);
+ INIT_SYMBOL(StoreFontClientFont);
+ INIT_SYMBOL(MakeAtom);
+ INIT_SYMBOL(ValidAtom);
+ INIT_SYMBOL(NameForAtom);
+ INIT_SYMBOL(register_fpe_functions);
+ INIT_DATA(serverClient);
+ INIT_DATA(serverGeneration);
+
+ inited = TRUE;
+ return inited;
+}
+
+#endif /* NO_WEAK_SYMBOLS && PIC */
int h = 0;
int r;
+ OVERRIDE_SYMBOL(MakeAtom, string, len, makeit);
+
hash = Hash (string, len);
if (hashTable)
{
weak int
ValidAtom(Atom atom)
{
+ OVERRIDE_SYMBOL(ValidAtom, atom);
return (atom != None) && (atom <= lastAtom);
}
weak char *
NameForAtom(Atom atom)
{
+ OVERRIDE_SYMBOL(NameForAtom, atom);
if (atom != None && atom <= lastAtom)
return reverseMap[atom]->name;
return NULL;
extern void BuiltinRegisterFpeFunctions(void);
-#ifndef NO_WEAK_SYMBOLS
/* make sure everything initializes themselves at least once */
weak unsigned long serverGeneration = 1;
-#endif
+
+unsigned long __GetServerGeneration (void);
+
+unsigned long
+__GetServerGeneration (void)
+{
+ OVERRIDE_DATA(serverGeneration);
+ return serverGeneration;
+}
weak void
register_fpe_functions (void)
{
+ OVERRIDE_SYMBOL(register_fpe_functions);
BuiltinRegisterFpeFunctions();
FontFileRegisterFpeFunctions();
#ifdef XFONT_FC
typedef struct _FontPatternCacheEntry {
struct _FontPatternCacheEntry *next, **prev;
short patlen;
- char *pattern;
+ const char *pattern;
int hash;
FontPtr pFont; /* associated font */
} FontPatternCacheEntryRec, *FontPatternCacheEntryPtr;
cache->entries[i].next = &cache->entries[i+1];
cache->entries[i].prev = 0;
cache->entries[i].pFont = 0;
- free (cache->entries[i].pattern);
+ free ((void *) cache->entries[i].pattern);
cache->entries[i].pattern = 0;
cache->entries[i].patlen = 0;
}
int i;
for (i = 0; i < NENTRIES; i++)
- free (cache->entries[i].pattern);
+ free ((void *) cache->entries[i].pattern);
free (cache);
}
/* add entry */
void
CacheFontPattern (FontPatternCachePtr cache,
- char *pattern,
+ const char *pattern,
int patlen,
FontPtr pFont)
{
if (e->next)
e->next->prev = e->prev;
*e->prev = e->next;
- free (e->pattern);
+ free ((void *) e->pattern);
}
/* set pattern */
memcpy (newpat, pattern, patlen);
/* find matching entry */
FontPtr
FindCachedFontPattern (FontPatternCachePtr cache,
- char *pattern,
+ const char *pattern,
int patlen)
{
int hash;
*e->prev = e->next;
e->next = cache->free;
cache->free = e;
- free (e->pattern);
+ free ((void *) e->pattern);
e->pattern = 0;
}
}