summaryrefslogtreecommitdiff
path: root/lib/libXfont2
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2019-12-14 14:57:45 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2019-12-14 14:57:45 +0000
commit860c380af8d3a8395cd992ff6fad2a5548e65cb6 (patch)
tree50cc261e8de5c5b1ffdc7ea2aa5ab8c0c37c9079 /lib/libXfont2
parent50c63ea9b06aba3aa4aac2489b30a01ee28a1362 (diff)
Update to libXfont2 2.0.4
Diffstat (limited to 'lib/libXfont2')
-rw-r--r--lib/libXfont2/ChangeLog251
-rw-r--r--lib/libXfont2/Makefile.am18
-rw-r--r--lib/libXfont2/Makefile.in98
-rw-r--r--lib/libXfont2/README89
-rw-r--r--lib/libXfont2/README.md90
-rw-r--r--lib/libXfont2/aclocal.m4283
-rw-r--r--lib/libXfont2/config.h.in12
-rwxr-xr-xlib/libXfont2/configure225
-rw-r--r--lib/libXfont2/configure.ac7
-rw-r--r--lib/libXfont2/include/X11/fonts/fntfil.h3
-rw-r--r--lib/libXfont2/include/X11/fonts/fntfilst.h6
-rw-r--r--lib/libXfont2/src/FreeType/ftenc.c4
-rw-r--r--lib/libXfont2/src/FreeType/ftfuncs.c39
-rw-r--r--lib/libXfont2/src/bitmap/bdfread.c9
-rw-r--r--lib/libXfont2/src/bitmap/bitmaputil.c3
-rw-r--r--lib/libXfont2/src/bitmap/bitscale.c17
-rw-r--r--lib/libXfont2/src/bitmap/pcfread.c13
-rw-r--r--lib/libXfont2/src/bitmap/pcfwrite.c3
-rw-r--r--lib/libXfont2/src/bitmap/snfread.c5
-rw-r--r--lib/libXfont2/src/fc/fsconvert.c3
-rw-r--r--lib/libXfont2/src/fc/fserve.c43
-rw-r--r--lib/libXfont2/src/fontfile/bitsource.c3
-rw-r--r--lib/libXfont2/src/fontfile/catalogue.c10
-rw-r--r--lib/libXfont2/src/fontfile/dirfile.c29
-rw-r--r--lib/libXfont2/src/fontfile/fontdir.c13
-rw-r--r--lib/libXfont2/src/fontfile/fontfile.c25
-rw-r--r--lib/libXfont2/src/fontfile/fontscale.c3
-rw-r--r--lib/libXfont2/src/fontfile/renderers.c3
-rw-r--r--lib/libXfont2/src/stubs/atom.c7
-rw-r--r--lib/libXfont2/src/util/fontnames.c9
-rw-r--r--lib/libXfont2/src/util/fontutil.c9
-rw-r--r--lib/libXfont2/src/util/fontxlfd.c128
-rw-r--r--lib/libXfont2/src/util/private.c5
-rw-r--r--lib/libXfont2/src/util/reallocarray.c43
-rw-r--r--lib/libXfont2/src/util/replace.h61
-rw-r--r--lib/libXfont2/src/util/strlcat.c58
-rw-r--r--lib/libXfont2/src/util/strlcpy.c53
-rw-r--r--lib/libXfont2/test/utils/README18
-rw-r--r--lib/libXfont2/test/utils/font-test-utils.c337
-rw-r--r--lib/libXfont2/test/utils/font-test-utils.h49
-rw-r--r--lib/libXfont2/test/utils/lsfontdir.c74
41 files changed, 1710 insertions, 448 deletions
diff --git a/lib/libXfont2/ChangeLog b/lib/libXfont2/ChangeLog
index 7ae2980a5..2875dd411 100644
--- a/lib/libXfont2/ChangeLog
+++ b/lib/libXfont2/ChangeLog
@@ -1,3 +1,194 @@
+commit ed8b8e9fe544ec51ab1b1dfaea6fced35470ad6c
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Sat Sep 14 11:34:03 2019 -0700
+
+ libXfont2 2.0.4
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit b46cd2fef2bfe192579930f29a830051670d4d00
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Sat Sep 14 11:32:02 2019 -0700
+
+ Add src/util/replace.h to noinst_HEADERS so it gets included in tarballs
+
+ Found when "make distcheck" failed.
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 5561a9dc835a249e58cfdb3c384547f6f401a15d
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Sat Aug 17 14:31:24 2019 -0700
+
+ fs_read_glyphs: check if rep is null before dereferencing
+
+ Resolves coverity warning def16 from the list in
+ https://gitlab.freedesktop.org/xorg/lib/libxfont/issues/6
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit c84ce6be6a7e2e70c9ab20b60bc7198699690d50
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Sat Aug 17 14:19:04 2019 -0700
+
+ CatalogueRescan: if opendir() fails, unref fpes, but don't free the cat
+
+ None of the callers of CatalogueRescan check for failure before accessing
+ the cat pointer so don't free it (especially without clearing the pointer
+ to it in fpe->private), just unref the contents.
+
+ Can only be triggered if somehow stat() succeeds on the directory, but
+ opendir fails anyway (removed between the calls? permission problem?).
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit c1c5c9aa4cacb9138d6a2e5d37619f7960b54536
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Sat Aug 17 13:56:03 2019 -0700
+
+ ComputeScaledProperties: check for valid pointers before making atoms
+
+ Resolves coverity warning def23 from the list in
+ https://gitlab.freedesktop.org/xorg/lib/libxfont/issues/6
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 78085e6b683b4e5a13b38508597a0c93ac2ed9ea
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Sat Aug 17 13:41:02 2019 -0700
+
+ stubs/atom.c: check for ResizeHashTable failure
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 3e0e36e4a9fee32105aa7c5cb6e089c495b92b10
+Author: Maya Rashish <maya@NetBSD.org>
+Date: Fri Aug 9 12:53:48 2019 +0300
+
+ Fix whitespace
+
+commit 194cb45ceb510c3e580460919cd7e5dd31a285c8
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Sun Aug 4 11:14:39 2019 -0700
+
+ fontxlfd.c: tell gcc that switch fallthrough is intentional
+
+ Quiets:
+ src/util/fontxlfd.c: In function ‘FontParseXLFDName’:
+ src/util/fontxlfd.c:450:14: warning: this statement may fall through [-Wimplicit-fallthrough=]
+ replaceChar = '*';
+ ~~~~~~~~~~~~^~~~~
+ src/util/fontxlfd.c:451:5: note: here
+ case FONT_XLFD_REPLACE_ZERO:
+ ^~~~
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit ddbee30d3525cdd66b84056affc407601680cc29
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Sat Aug 3 19:29:05 2019 -0700
+
+ Convert multiplying malloc calls to use mallocarray instead
+
+ Introduces mallocarray as a macro calling reallocarray with a NULL
+ pointer for the old allocation.
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit f54470dab5b392380df61a22b4b4bef685b6cee2
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Sat Aug 3 19:09:19 2019 -0700
+
+ Convert multiplying realloc calls to use reallocarray instead
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 27207d35d4b4bbd5d2b2c5f7e13a61ea43d04a4a
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Sat Aug 3 16:13:21 2019 -0700
+
+ Add reallocarray fallback if not provided by libc nor libbsd
+
+ Implementation copied from the Xserver
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 2178c7445a3464bd69637ad91a2dd0320a60e0df
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Sat Aug 3 18:19:11 2019 -0700
+
+ Use bounds checking string functions everywhere
+
+ Replace strcpy, strcat, sprintf with strlcpy, strlcat, snprintf
+ everywhere, even where there were already bounds checks in place,
+ to reduce time spent checking static analysis results.
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit d4c941ea8b1dc07a14efce656bff58d31a14c985
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Sat Aug 3 16:05:21 2019 -0700
+
+ Add strlcat & strlcpy fallbacks if not provided by libc nor libbsd
+
+ Implementations copied from the Xserver
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit c4ed2e069dc8aa5b8b7ef2fc926ae8584ff2a67b
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Sat Aug 3 13:45:54 2019 -0700
+
+ Add some unit testing utilities
+
+ The test/utils directory contains some standalone test programs for testing
+ libXfont funtionality without needing a full X server session. They could
+ be used to generate automated unit testing in the future, but that work has
+ not yet been done.
+
+ [v2: updated original work from libXfont 1.5 to 2.0 API & makefiles]
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 77ae4048564eff2e96b80cedfac013877e46d506
+Author: Adam Jackson <ajax@redhat.com>
+Date: Wed Jan 4 12:13:04 2017 -0500
+
+ fontfile: Remove unused 'bc' slot from _FontEntry
+
+ Whatever this is, we're not using it. On my machine we allocate about
+ 1100 of these structs, and this change reduces the struct from 152 to 48
+ bytes, so this saves about 100k of memory.
+
+ Signed-off-by: Adam Jackson <ajax@redhat.com>
+
+commit 6624b5e705da8333a3bc63d1ddeea6b11e831e24
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Sat Mar 16 12:40:03 2019 -0700
+
+ Update configure.ac bug URL for gitlab migration
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 66a26687b2b86b53c315544483b740deb6f01c1e
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Mon Nov 19 22:05:10 2018 -0800
+
+ Update README for gitlab migration
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 099ed6fa9f293d283163b138830d43bbd47c5df1
+Author: Rin Okuyama <rin@NetBSD.org>
+Date: Tue Feb 21 06:18:37 2017 +0000
+
+ avoid -Wformat errors from clang when building with -DDEBUG
+
+ https://bugs.freedesktop.org/show_bug.cgi?id=99882
+
+ Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
commit cdb2f990348c3bd1407022f7e0e5fcba552d539f
Author: Matthieu Herrb <matthieu@herrb.eu>
Date: Sat Nov 25 12:01:16 2017 +0100
@@ -118,9 +309,9 @@ Date: Wed May 18 11:52:27 2016 -0400
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
+ 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>
@@ -135,21 +326,21 @@ Date: Mon May 30 00:46:21 2016 -0700
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);
+ 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
@@ -1584,7 +1775,7 @@ Date: Wed Apr 14 05:58:28 2010 -0500
Conflicts:
- ChangeLog
+ ChangeLog
Signed-off-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
@@ -2397,7 +2588,7 @@ Date: Tue Jun 19 10:38:02 2007 -0400
This patch adds a new FPE type, which will match font path elements of the
form
- catalogue:<dir>
+ catalogue:<dir>
The dir specified after the catalogue: prefix will be scanned for symlinks
and each symlink destination will be added as a local fontfile FPE.
@@ -2407,22 +2598,22 @@ Date: Tue Jun 19 10:38:02 2007 -0400
An example configuration:
- 75dpi:unscaled:pri=20 -> /usr/share/X11/fonts/75dpi
- ghostscript:pri=60 -> /usr/share/fonts/default/ghostscript
- misc:unscaled:pri=10 -> /usr/share/X11/fonts/misc
- type1:pri=40 -> /usr/share/X11/fonts/Type1
- type1:pri=50 -> /usr/share/fonts/default/Type1
+ 75dpi:unscaled:pri=20 -> /usr/share/X11/fonts/75dpi
+ ghostscript:pri=60 -> /usr/share/fonts/default/ghostscript
+ misc:unscaled:pri=10 -> /usr/share/X11/fonts/misc
+ type1:pri=40 -> /usr/share/X11/fonts/Type1
+ type1:pri=50 -> /usr/share/fonts/default/Type1
will add /usr/share/X11/fonts/misc as the first FPE with the attribute
'unscaled', second FPE will be /usr/share/X11/fonts/75dpi, also with
the attribute unscaled etc. This is functionally equivalent to setting
the following font path:
- /usr/share/X11/fonts/misc:unscaled,
- /usr/share/X11/fonts/75dpi:unscaled,
- /usr/share/X11/fonts/Type1,
- /usr/share/fonts/default/Type1,
- /usr/share/fonts/default/ghostscript
+ /usr/share/X11/fonts/misc:unscaled,
+ /usr/share/X11/fonts/75dpi:unscaled,
+ /usr/share/X11/fonts/Type1,
+ /usr/share/fonts/default/Type1,
+ /usr/share/fonts/default/ghostscript
The motivation is to let font packages add a symlink to the new font
directory they provide instead of rewriting either the Xorg config file
diff --git a/lib/libXfont2/Makefile.am b/lib/libXfont2/Makefile.am
index c1a3db23b..5af2e237a 100644
--- a/lib/libXfont2/Makefile.am
+++ b/lib/libXfont2/Makefile.am
@@ -40,7 +40,8 @@ noinst_HEADERS = \
include/X11/fonts/pcf.h \
include/libxfontint.h \
src/FreeType/ft.h \
- src/FreeType/ftfuncs.h
+ src/FreeType/ftfuncs.h \
+ src/util/replace.h
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = xfont2.pc
@@ -65,7 +66,7 @@ libXfont2_la_SOURCES = \
libXfont2_la_LDFLAGS = -version-number 2:0:0 -no-undefined
-libXfont2_la_LIBADD = $(Z_LIBS) $(MATH_LIBS) $(XFONT_LIBS)
+libXfont2_la_LIBADD = $(Z_LIBS) $(MATH_LIBS) $(XFONT_LIBS) $(LTLIBOBJS)
if XFONT_FONTFILE
libXfont2_la_SOURCES += \
@@ -155,7 +156,18 @@ libXfont2_la_SOURCES += \
src/fc/fstrans.c
endif
-EXTRA_DIST = src/builtins/buildfont
+EXTRA_DIST = src/builtins/buildfont README.md
+
+# Test utilities
+EXTRA_DIST += test/utils/README
+
+TEST_UTIL_SRCS = test/utils/font-test-utils.c test/utils/font-test-utils.h
+
+noinst_PROGRAMS = lsfontdir
+
+lsfontdir_SOURCES = test/utils/lsfontdir.c $(TEST_UTIL_SRCS)
+lsfontdir_LDADD = libXfont2.la $(LTLIBOBJS)
+
MAINTAINERCLEANFILES = ChangeLog INSTALL
diff --git a/lib/libXfont2/Makefile.in b/lib/libXfont2/Makefile.in
index 2cf07260d..e0d0c0dc4 100644
--- a/lib/libXfont2/Makefile.in
+++ b/lib/libXfont2/Makefile.in
@@ -37,6 +37,7 @@
+
VPATH = @srcdir@
am__make_dryrun = \
{ \
@@ -137,13 +138,16 @@ host_triplet = @host@
@XFONT_FC_TRUE@ src/fc/fslibos.h \
@XFONT_FC_TRUE@ src/fc/fstrans.c
+noinst_PROGRAMS = lsfontdir$(EXEEXT)
subdir = .
-DIST_COMMON = README $(am__configure_deps) $(libXfontinclude_HEADERS) \
+DIST_COMMON = $(am__configure_deps) $(libXfontinclude_HEADERS) \
$(noinst_HEADERS) $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(srcdir)/config.h.in $(srcdir)/xfont2.pc.in \
- $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL \
- compile config.guess config.sub depcomp install-sh ltmain.sh \
- missing
+ $(top_srcdir)/configure $(top_srcdir)/src/util/reallocarray.c \
+ $(top_srcdir)/src/util/strlcat.c \
+ $(top_srcdir)/src/util/strlcpy.c AUTHORS COPYING ChangeLog \
+ INSTALL compile config.guess config.sub depcomp install-sh \
+ ltmain.sh missing
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@@ -185,9 +189,10 @@ am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)" \
"$(DESTDIR)$(libXfontincludedir)"
LTLIBRARIES = $(lib_LTLIBRARIES)
am__DEPENDENCIES_1 =
+LIBOBJDIR = src/util/
@XFONT_FREETYPE_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
libXfont2_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(LTLIBOBJS) \
$(am__DEPENDENCIES_2)
am__libXfont2_la_SOURCES_DIST = src/stubs/atom.c \
src/stubs/libxfontstubs.c src/util/fontaccel.c \
@@ -268,6 +273,12 @@ am__v_lt_1 =
libXfont2_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(libXfont2_la_LDFLAGS) $(LDFLAGS) -o $@
+PROGRAMS = $(noinst_PROGRAMS)
+am__objects_11 = test/utils/font-test-utils.$(OBJEXT)
+am_lsfontdir_OBJECTS = test/utils/lsfontdir.$(OBJEXT) \
+ $(am__objects_11)
+lsfontdir_OBJECTS = $(am_lsfontdir_OBJECTS)
+lsfontdir_DEPENDENCIES = libXfont2.la $(LTLIBOBJS)
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
@@ -302,8 +313,8 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
-SOURCES = $(libXfont2_la_SOURCES)
-DIST_SOURCES = $(am__libXfont2_la_SOURCES_DIST)
+SOURCES = $(libXfont2_la_SOURCES) $(lsfontdir_SOURCES)
+DIST_SOURCES = $(am__libXfont2_la_SOURCES_DIST) $(lsfontdir_SOURCES)
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-dvi-recursive install-exec-recursive \
@@ -541,7 +552,8 @@ noinst_HEADERS = \
include/X11/fonts/pcf.h \
include/libxfontint.h \
src/FreeType/ft.h \
- src/FreeType/ftfuncs.h
+ src/FreeType/ftfuncs.h \
+ src/util/replace.h
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = xfont2.pc
@@ -558,8 +570,13 @@ libXfont2_la_SOURCES = src/stubs/atom.c src/stubs/libxfontstubs.c \
$(am__append_12)
libXfont2_la_LDFLAGS = -version-number 2:0:0 -no-undefined
libXfont2_la_LIBADD = $(Z_LIBS) $(MATH_LIBS) $(XFONT_LIBS) \
- $(am__append_4)
-EXTRA_DIST = src/builtins/buildfont
+ $(LTLIBOBJS) $(am__append_4)
+
+# Test utilities
+EXTRA_DIST = src/builtins/buildfont README.md test/utils/README
+TEST_UTIL_SRCS = test/utils/font-test-utils.c test/utils/font-test-utils.h
+lsfontdir_SOURCES = test/utils/lsfontdir.c $(TEST_UTIL_SRCS)
+lsfontdir_LDADD = libXfont2.la $(LTLIBOBJS)
MAINTAINERCLEANFILES = ChangeLog INSTALL
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
@@ -796,6 +813,28 @@ src/fc/fstrans.lo: src/fc/$(am__dirstamp) \
libXfont2.la: $(libXfont2_la_OBJECTS) $(libXfont2_la_DEPENDENCIES) $(EXTRA_libXfont2_la_DEPENDENCIES)
$(AM_V_CCLD)$(libXfont2_la_LINK) -rpath $(libdir) $(libXfont2_la_OBJECTS) $(libXfont2_la_LIBADD) $(LIBS)
+clean-noinstPROGRAMS:
+ @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+test/utils/$(am__dirstamp):
+ @$(MKDIR_P) test/utils
+ @: > test/utils/$(am__dirstamp)
+test/utils/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) test/utils/$(DEPDIR)
+ @: > test/utils/$(DEPDIR)/$(am__dirstamp)
+test/utils/lsfontdir.$(OBJEXT): test/utils/$(am__dirstamp) \
+ test/utils/$(DEPDIR)/$(am__dirstamp)
+test/utils/font-test-utils.$(OBJEXT): test/utils/$(am__dirstamp) \
+ test/utils/$(DEPDIR)/$(am__dirstamp)
+lsfontdir$(EXEEXT): $(lsfontdir_OBJECTS) $(lsfontdir_DEPENDENCIES) $(EXTRA_lsfontdir_DEPENDENCIES)
+ @rm -f lsfontdir$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(lsfontdir_OBJECTS) $(lsfontdir_LDADD) $(LIBS)
+
mostlyclean-compile:
-rm -f *.$(OBJEXT)
-rm -f src/FreeType/*.$(OBJEXT)
@@ -812,6 +851,7 @@ mostlyclean-compile:
-rm -f src/stubs/*.lo
-rm -f src/util/*.$(OBJEXT)
-rm -f src/util/*.lo
+ -rm -f test/utils/*.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@@ -865,7 +905,12 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@src/util/$(DEPDIR)/miscutil.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/util/$(DEPDIR)/patcache.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/util/$(DEPDIR)/private.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/util/$(DEPDIR)/reallocarray.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/util/$(DEPDIR)/strlcat.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/util/$(DEPDIR)/strlcpy.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/util/$(DEPDIR)/utilbitmap.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@test/utils/$(DEPDIR)/font-test-utils.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@test/utils/$(DEPDIR)/lsfontdir.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@@ -1270,7 +1315,8 @@ distcleancheck: distclean
exit 1; } >&2
check-am: all-am
check: check-recursive
-all-am: Makefile $(LTLIBRARIES) $(DATA) $(HEADERS) config.h
+all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(DATA) $(HEADERS) \
+ config.h
installdirs: installdirs-recursive
installdirs-am:
for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(libXfontincludedir)"; do \
@@ -1296,6 +1342,8 @@ install-strip:
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
+ -test -z "$(LIBOBJS)" || rm -f $(LIBOBJS)
+ -test -z "$(LTLIBOBJS)" || rm -f $(LTLIBOBJS)
clean-generic:
@@ -1316,6 +1364,8 @@ distclean-generic:
-rm -f src/stubs/$(am__dirstamp)
-rm -f src/util/$(DEPDIR)/$(am__dirstamp)
-rm -f src/util/$(am__dirstamp)
+ -rm -f test/utils/$(DEPDIR)/$(am__dirstamp)
+ -rm -f test/utils/$(am__dirstamp)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@@ -1324,11 +1374,11 @@ maintainer-clean-generic:
clean: clean-recursive
clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
- mostlyclean-am
+ clean-noinstPROGRAMS mostlyclean-am
distclean: distclean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
- -rm -rf src/FreeType/$(DEPDIR) src/bitmap/$(DEPDIR) src/builtins/$(DEPDIR) src/fc/$(DEPDIR) src/fontfile/$(DEPDIR) src/stubs/$(DEPDIR) src/util/$(DEPDIR)
+ -rm -rf src/FreeType/$(DEPDIR) src/bitmap/$(DEPDIR) src/builtins/$(DEPDIR) src/fc/$(DEPDIR) src/fontfile/$(DEPDIR) src/stubs/$(DEPDIR) src/util/$(DEPDIR) test/utils/$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-hdr distclean-libtool distclean-tags
@@ -1376,7 +1426,7 @@ installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
- -rm -rf src/FreeType/$(DEPDIR) src/bitmap/$(DEPDIR) src/builtins/$(DEPDIR) src/fc/$(DEPDIR) src/fontfile/$(DEPDIR) src/stubs/$(DEPDIR) src/util/$(DEPDIR)
+ -rm -rf src/FreeType/$(DEPDIR) src/bitmap/$(DEPDIR) src/builtins/$(DEPDIR) src/fc/$(DEPDIR) src/fontfile/$(DEPDIR) src/stubs/$(DEPDIR) src/util/$(DEPDIR) test/utils/$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
@@ -1402,16 +1452,16 @@ uninstall-am: uninstall-libLTLIBRARIES \
.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
all all-am am--refresh check check-am clean clean-cscope \
- clean-generic clean-libLTLIBRARIES clean-libtool cscope \
- cscopelist cscopelist-recursive ctags ctags-recursive dist \
- dist-all dist-bzip2 dist-gzip dist-hook dist-lzip dist-shar \
- dist-tarZ dist-xz dist-zip distcheck distclean \
- distclean-compile distclean-generic distclean-hdr \
- distclean-libtool distclean-tags distcleancheck distdir \
- distuninstallcheck dvi dvi-am html html-am info info-am \
- install install-am install-data install-data-am install-dvi \
- install-dvi-am install-exec install-exec-am install-html \
- install-html-am install-info install-info-am \
+ clean-generic clean-libLTLIBRARIES clean-libtool \
+ clean-noinstPROGRAMS cscope cscopelist cscopelist-recursive \
+ ctags ctags-recursive dist dist-all dist-bzip2 dist-gzip \
+ dist-hook dist-lzip dist-shar dist-tarZ dist-xz dist-zip \
+ distcheck distclean distclean-compile distclean-generic \
+ distclean-hdr distclean-libtool distclean-tags distcleancheck \
+ distdir distuninstallcheck dvi dvi-am html html-am info \
+ info-am install install-am install-data install-data-am \
+ install-dvi install-dvi-am install-exec install-exec-am \
+ install-html install-html-am install-info install-info-am \
install-libLTLIBRARIES install-libXfontincludeHEADERS \
install-man install-pdf install-pdf-am install-pkgconfigDATA \
install-ps install-ps-am install-strip installcheck \
diff --git a/lib/libXfont2/README b/lib/libXfont2/README
deleted file mode 100644
index de1512f3b..000000000
--- a/lib/libXfont2/README
+++ /dev/null
@@ -1,89 +0,0 @@
-libXfont provides the core of the legacy X11 font system, handling the index
-files (fonts.dir, fonts.alias, fonts.scale), the various font file formats,
-and rasterizing them. It is used by the X servers, and will eventually be
-used by the X Font Server (xfs), but should not be used by normal X11 clients.
-X11 clients access fonts via either the new APIs in libXft, or the legacy
-APIs in libX11.
-
-This version of libXfont is not compatible with xfs, or with the legacy
-bdftopcf utility; these packages require libXfont 1.5, not libXfont 2.0
-or later. The two versions can be installed in parallel, and eventually
-the need for 1.5 will go away. We apologize for the inconvenience.
-
-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
-
-All questions regarding this software should be directed at the
-Xorg mailing list:
-
- http://lists.freedesktop.org/mailman/listinfo/xorg
-
-The master development code repository can be found at:
-
- git://anongit.freedesktop.org/git/xorg/lib/libXfont
-
- http://cgit.freedesktop.org/xorg/lib/libXfont
-
-For more information on the git code manager, see:
-
- http://wiki.x.org/wiki/GitPage
diff --git a/lib/libXfont2/README.md b/lib/libXfont2/README.md
new file mode 100644
index 000000000..868b8a5e4
--- /dev/null
+++ b/lib/libXfont2/README.md
@@ -0,0 +1,90 @@
+libXfont - X font handling library for server & utilities
+---------------------------------------------------------
+
+libXfont provides the core of the legacy X11 font system, handling the index
+files (fonts.dir, fonts.alias, fonts.scale), the various font file formats,
+and rasterizing them. It is used by the X servers, and will eventually be
+used by the X Font Server (xfs), but should not be used by normal X11 clients.
+X11 clients access fonts via either the new APIs in libXft, or the legacy
+APIs in libX11.
+
+This version of libXfont is not compatible with xfs, or with the legacy
+bdftopcf utility; these packages require libXfont 1.5, not libXfont 2.0
+or later. The two versions can be installed in parallel, and eventually
+the need for 1.5 will go away. We apologize for the inconvenience.
+
+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 https://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.
+
+--------------------------------------------------------------------------
+
+All questions regarding this software should be directed at the
+Xorg mailing list:
+
+ https://lists.x.org/mailman/listinfo/xorg
+
+The master development code repository can be found at:
+
+ https://gitlab.freedesktop.org/xorg/lib/libXfont
+
+Please submit bug reports and requests to merge patches there.
+
+For patch submission instructions, see:
+
+ https://www.x.org/wiki/Development/Documentation/SubmittingPatches
diff --git a/lib/libXfont2/aclocal.m4 b/lib/libXfont2/aclocal.m4
index fe155db4d..c3bab31f9 100644
--- a/lib/libXfont2/aclocal.m4
+++ b/lib/libXfont2/aclocal.m4
@@ -8606,32 +8606,63 @@ m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])])
m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])])
m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])])
-# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
-# serial 1 (pkg-config-0.24)
-#
-# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# PKG_PROG_PKG_CONFIG([MIN-VERSION])
-# ----------------------------------
+dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
+dnl serial 11 (pkg-config-0.29.1)
+dnl
+dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
+dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+dnl 02111-1307, USA.
+dnl
+dnl As a special exception to the GNU General Public License, if you
+dnl distribute this file as part of a program that contains a
+dnl configuration script generated by Autoconf, you may include it under
+dnl the same distribution terms that you use for the rest of that
+dnl program.
+
+dnl PKG_PREREQ(MIN-VERSION)
+dnl -----------------------
+dnl Since: 0.29
+dnl
+dnl Verify that the version of the pkg-config macros are at least
+dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
+dnl installed version of pkg-config, this checks the developer's version
+dnl of pkg.m4 when generating configure.
+dnl
+dnl To ensure that this macro is defined, also add:
+dnl m4_ifndef([PKG_PREREQ],
+dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
+dnl
+dnl See the "Since" comment for each macro you use to see what version
+dnl of the macros you require.
+m4_defun([PKG_PREREQ],
+[m4_define([PKG_MACROS_VERSION], [0.29.1])
+m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
+ [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
+])dnl PKG_PREREQ
+
+dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
+dnl ----------------------------------
+dnl Since: 0.16
+dnl
+dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
+dnl first found in the path. Checks that the version of pkg-config found
+dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
+dnl used since that's the first version where most current features of
+dnl pkg-config existed.
AC_DEFUN([PKG_PROG_PKG_CONFIG],
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
@@ -8653,18 +8684,19 @@ if test -n "$PKG_CONFIG"; then
PKG_CONFIG=""
fi
fi[]dnl
-])# PKG_PROG_PKG_CONFIG
+])dnl PKG_PROG_PKG_CONFIG
-# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
-#
-# Check to see whether a particular set of modules exists. Similar
-# to PKG_CHECK_MODULES(), but does not set variables or print errors.
-#
-# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
-# only at the first occurence in configure.ac, so if the first place
-# it's called might be skipped (such as if it is within an "if", you
-# have to call PKG_CHECK_EXISTS manually
-# --------------------------------------------------------------
+dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------------------------------
+dnl Since: 0.18
+dnl
+dnl Check to see whether a particular set of modules exists. Similar to
+dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
+dnl
+dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+dnl only at the first occurence in configure.ac, so if the first place
+dnl it's called might be skipped (such as if it is within an "if", you
+dnl have to call PKG_CHECK_EXISTS manually
AC_DEFUN([PKG_CHECK_EXISTS],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
if test -n "$PKG_CONFIG" && \
@@ -8674,8 +8706,10 @@ m4_ifvaln([$3], [else
$3])dnl
fi])
-# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
-# ---------------------------------------------
+dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+dnl ---------------------------------------------
+dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
+dnl pkg_failed based on the result.
m4_define([_PKG_CONFIG],
[if test -n "$$1"; then
pkg_cv_[]$1="$$1"
@@ -8687,10 +8721,11 @@ m4_define([_PKG_CONFIG],
else
pkg_failed=untried
fi[]dnl
-])# _PKG_CONFIG
+])dnl _PKG_CONFIG
-# _PKG_SHORT_ERRORS_SUPPORTED
-# -----------------------------
+dnl _PKG_SHORT_ERRORS_SUPPORTED
+dnl ---------------------------
+dnl Internal check to see if pkg-config supports short errors.
AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
@@ -8698,19 +8733,17 @@ if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
else
_pkg_short_errors_supported=no
fi[]dnl
-])# _PKG_SHORT_ERRORS_SUPPORTED
+])dnl _PKG_SHORT_ERRORS_SUPPORTED
-# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
-# [ACTION-IF-NOT-FOUND])
-#
-#
-# Note that if there is a possibility the first call to
-# PKG_CHECK_MODULES might not happen, you should be sure to include an
-# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
-#
-#
-# --------------------------------------------------------------
+dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl [ACTION-IF-NOT-FOUND])
+dnl --------------------------------------------------------------
+dnl Since: 0.4.0
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
+dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
AC_DEFUN([PKG_CHECK_MODULES],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
@@ -8764,16 +8797,40 @@ else
AC_MSG_RESULT([yes])
$3
fi[]dnl
-])# PKG_CHECK_MODULES
+])dnl PKG_CHECK_MODULES
-# PKG_INSTALLDIR(DIRECTORY)
-# -------------------------
-# Substitutes the variable pkgconfigdir as the location where a module
-# should install pkg-config .pc files. By default the directory is
-# $libdir/pkgconfig, but the default can be changed by passing
-# DIRECTORY. The user can override through the --with-pkgconfigdir
-# parameter.
+dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl [ACTION-IF-NOT-FOUND])
+dnl ---------------------------------------------------------------------
+dnl Since: 0.29
+dnl
+dnl Checks for existence of MODULES and gathers its build flags with
+dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
+dnl and VARIABLE-PREFIX_LIBS from --libs.
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
+dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
+dnl configure.ac.
+AC_DEFUN([PKG_CHECK_MODULES_STATIC],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+_save_PKG_CONFIG=$PKG_CONFIG
+PKG_CONFIG="$PKG_CONFIG --static"
+PKG_CHECK_MODULES($@)
+PKG_CONFIG=$_save_PKG_CONFIG[]dnl
+])dnl PKG_CHECK_MODULES_STATIC
+
+
+dnl PKG_INSTALLDIR([DIRECTORY])
+dnl -------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable pkgconfigdir as the location where a module
+dnl should install pkg-config .pc files. By default the directory is
+dnl $libdir/pkgconfig, but the default can be changed by passing
+dnl DIRECTORY. The user can override through the --with-pkgconfigdir
+dnl parameter.
AC_DEFUN([PKG_INSTALLDIR],
[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
m4_pushdef([pkg_description],
@@ -8784,16 +8841,18 @@ AC_ARG_WITH([pkgconfigdir],
AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
m4_popdef([pkg_default])
m4_popdef([pkg_description])
-]) dnl PKG_INSTALLDIR
+])dnl PKG_INSTALLDIR
-# PKG_NOARCH_INSTALLDIR(DIRECTORY)
-# -------------------------
-# Substitutes the variable noarch_pkgconfigdir as the location where a
-# module should install arch-independent pkg-config .pc files. By
-# default the directory is $datadir/pkgconfig, but the default can be
-# changed by passing DIRECTORY. The user can override through the
-# --with-noarch-pkgconfigdir parameter.
+dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
+dnl --------------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable noarch_pkgconfigdir as the location where a
+dnl module should install arch-independent pkg-config .pc files. By
+dnl default the directory is $datadir/pkgconfig, but the default can be
+dnl changed by passing DIRECTORY. The user can override through the
+dnl --with-noarch-pkgconfigdir parameter.
AC_DEFUN([PKG_NOARCH_INSTALLDIR],
[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
m4_pushdef([pkg_description],
@@ -8804,7 +8863,24 @@ AC_ARG_WITH([noarch-pkgconfigdir],
AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
m4_popdef([pkg_default])
m4_popdef([pkg_description])
-]) dnl PKG_NOARCH_INSTALLDIR
+])dnl PKG_NOARCH_INSTALLDIR
+
+
+dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
+dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------
+dnl Since: 0.28
+dnl
+dnl Retrieves the value of the pkg-config variable for the given module.
+AC_DEFUN([PKG_CHECK_VAR],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
+
+_PKG_CONFIG([$1], [variable="][$3]["], [$2])
+AS_VAR_COPY([$1], [pkg_cv_][$1])
+
+AS_VAR_IF([$1], [""], [$5], [$4])dnl
+])dnl PKG_CHECK_VAR
# Copyright (C) 2002-2012 Free Software Foundation, Inc.
#
@@ -9829,7 +9905,7 @@ AC_SUBST([am__untar])
dnl xorg-macros.m4. Generated from xorg-macros.m4.in xorgversion.m4 by configure.
dnl
-dnl Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+dnl Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
dnl
dnl Permission is hereby granted, free of charge, to any person obtaining a
dnl copy of this software and associated documentation files (the "Software"),
@@ -9866,7 +9942,7 @@ dnl DEALINGS IN THE SOFTWARE.
# See the "minimum version" comment for each macro you use to see what
# version you require.
m4_defun([XORG_MACROS_VERSION],[
-m4_define([vers_have], [1.19.0])
+m4_define([vers_have], [1.19.2])
m4_define([maj_have], m4_substr(vers_have, 0, m4_index(vers_have, [.])))
m4_define([maj_needed], m4_substr([$1], 0, m4_index([$1], [.])))
m4_if(m4_cmp(maj_have, maj_needed), 0,,
@@ -9944,6 +10020,17 @@ AC_DEFUN([XORG_MANPAGE_SECTIONS],[
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([AC_PROG_SED])
+case $host_os in
+ solaris*)
+ # Solaris 2.0 - 11.3 use SysV man page section numbers, so we
+ # check for a man page file found in later versions that use
+ # traditional section numbers instead
+ AC_CHECK_FILE([/usr/share/man/man7/attributes.7],
+ [SYSV_MAN_SECTIONS=false], [SYSV_MAN_SECTIONS=true])
+ ;;
+ *) SYSV_MAN_SECTIONS=false ;;
+esac
+
if test x$APP_MAN_SUFFIX = x ; then
APP_MAN_SUFFIX=1
fi
@@ -9959,9 +10046,9 @@ if test x$LIB_MAN_DIR = x ; then
fi
if test x$FILE_MAN_SUFFIX = x ; then
- case $host_os in
- solaris*) FILE_MAN_SUFFIX=4 ;;
- *) FILE_MAN_SUFFIX=5 ;;
+ case $SYSV_MAN_SECTIONS in
+ true) FILE_MAN_SUFFIX=4 ;;
+ *) FILE_MAN_SUFFIX=5 ;;
esac
fi
if test x$FILE_MAN_DIR = x ; then
@@ -9969,9 +10056,9 @@ if test x$FILE_MAN_DIR = x ; then
fi
if test x$MISC_MAN_SUFFIX = x ; then
- case $host_os in
- solaris*) MISC_MAN_SUFFIX=5 ;;
- *) MISC_MAN_SUFFIX=7 ;;
+ case $SYSV_MAN_SECTIONS in
+ true) MISC_MAN_SUFFIX=5 ;;
+ *) MISC_MAN_SUFFIX=7 ;;
esac
fi
if test x$MISC_MAN_DIR = x ; then
@@ -9979,9 +10066,9 @@ if test x$MISC_MAN_DIR = x ; then
fi
if test x$DRIVER_MAN_SUFFIX = x ; then
- case $host_os in
- solaris*) DRIVER_MAN_SUFFIX=7 ;;
- *) DRIVER_MAN_SUFFIX=4 ;;
+ case $SYSV_MAN_SECTIONS in
+ true) DRIVER_MAN_SUFFIX=7 ;;
+ *) DRIVER_MAN_SUFFIX=4 ;;
esac
fi
if test x$DRIVER_MAN_DIR = x ; then
@@ -9989,9 +10076,9 @@ if test x$DRIVER_MAN_DIR = x ; then
fi
if test x$ADMIN_MAN_SUFFIX = x ; then
- case $host_os in
- solaris*) ADMIN_MAN_SUFFIX=1m ;;
- *) ADMIN_MAN_SUFFIX=8 ;;
+ case $SYSV_MAN_SECTIONS in
+ true) ADMIN_MAN_SUFFIX=1m ;;
+ *) ADMIN_MAN_SUFFIX=8 ;;
esac
fi
if test x$ADMIN_MAN_DIR = x ; then
@@ -10252,13 +10339,24 @@ m4_ifval([$1],
fi])
# Test for the ability of xmlto to generate a text target
+#
+# NOTE: xmlto 0.0.27 or higher return a non-zero return code in the
+# following test for empty XML docbook files.
+# For compatibility reasons use the following empty XML docbook file and if
+# it fails try it again with a non-empty XML file.
have_xmlto_text=no
cat > conftest.xml << "EOF"
EOF
AS_IF([test "$have_xmlto" = yes],
[AS_IF([$XMLTO --skip-validation txt conftest.xml >/dev/null 2>&1],
[have_xmlto_text=yes],
- [AC_MSG_WARN([xmlto cannot generate text format, this format skipped])])])
+ [# Try it again with a non-empty XML file.
+ cat > conftest.xml << "EOF"
+<x></x>
+EOF
+ AS_IF([$XMLTO --skip-validation txt conftest.xml >/dev/null 2>&1],
+ [have_xmlto_text=yes],
+ [AC_MSG_WARN([xmlto cannot generate text format, this format skipped])])])])
rm -f conftest.xml
AM_CONDITIONAL([HAVE_XMLTO_TEXT], [test $have_xmlto_text = yes])
AM_CONDITIONAL([HAVE_XMLTO], [test "$have_xmlto" = yes])
@@ -11654,8 +11752,9 @@ AC_REQUIRE([PKG_PROG_PKG_CONFIG])
macros_datadir=`$PKG_CONFIG --print-errors --variable=pkgdatadir xorg-macros`
INSTALL_CMD="(cp -f "$macros_datadir/INSTALL" \$(top_srcdir)/.INSTALL.tmp && \
mv \$(top_srcdir)/.INSTALL.tmp \$(top_srcdir)/INSTALL) \
-|| (rm -f \$(top_srcdir)/.INSTALL.tmp; touch \$(top_srcdir)/INSTALL; \
-echo 'util-macros \"pkgdatadir\" from xorg-macros.pc not found: installing possibly empty INSTALL.' >&2)"
+|| (rm -f \$(top_srcdir)/.INSTALL.tmp; test -e \$(top_srcdir)/INSTALL || ( \
+touch \$(top_srcdir)/INSTALL; \
+echo 'failed to copy INSTALL from util-macros: installing empty INSTALL.' >&2))"
AC_SUBST([INSTALL_CMD])
]) # XORG_INSTALL
dnl Copyright 2005 Red Hat, Inc
@@ -11716,10 +11815,11 @@ AC_DEFUN([XORG_RELEASE_VERSION],[
#
#
AC_DEFUN([XORG_CHANGELOG], [
-CHANGELOG_CMD="(GIT_DIR=\$(top_srcdir)/.git git log > \$(top_srcdir)/.changelog.tmp && \
+CHANGELOG_CMD="((GIT_DIR=\$(top_srcdir)/.git git log > \$(top_srcdir)/.changelog.tmp) 2>/dev/null && \
mv \$(top_srcdir)/.changelog.tmp \$(top_srcdir)/ChangeLog) \
-|| (rm -f \$(top_srcdir)/.changelog.tmp; touch \$(top_srcdir)/ChangeLog; \
-echo 'git directory not found: installing possibly empty changelog.' >&2)"
+|| (rm -f \$(top_srcdir)/.changelog.tmp; test -e \$(top_srcdir)/ChangeLog || ( \
+touch \$(top_srcdir)/ChangeLog; \
+echo 'git failed to create ChangeLog: installing empty ChangeLog.' >&2))"
AC_SUBST([CHANGELOG_CMD])
]) # XORG_CHANGELOG
@@ -11859,6 +11959,9 @@ AC_DEFUN([XTRANS_CONNECTION_FLAGS],[
AC_DEFINE(LOCALCONN,1,[Support os-specific local connections])
fi
+ # Other functions Xtrans may need
+ AC_CHECK_FUNCS([strcasecmp strlcpy])
+
]) # XTRANS_CONNECTION_FLAGS
diff --git a/lib/libXfont2/config.h.in b/lib/libXfont2/config.h.in
index abbc2c62c..beb9c8f77 100644
--- a/lib/libXfont2/config.h.in
+++ b/lib/libXfont2/config.h.in
@@ -27,6 +27,9 @@
/* Define to 1 if you have the `readlink' function. */
#undef HAVE_READLINK
+/* Define to 1 if you have the `reallocarray' function. */
+#undef HAVE_REALLOCARRAY
+
/* Define to 1 if the system has the type `socklen_t'. */
#undef HAVE_SOCKLEN_T
@@ -36,12 +39,21 @@
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
+/* Define to 1 if you have the `strcasecmp' function. */
+#undef HAVE_STRCASECMP
+
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
+/* Define to 1 if you have the `strlcat' function. */
+#undef HAVE_STRLCAT
+
+/* Define to 1 if you have the `strlcpy' function. */
+#undef HAVE_STRLCPY
+
/* Define to 1 if you have the <sys/poll.h> header file. */
#undef HAVE_SYS_POLL_H
diff --git a/lib/libXfont2/configure b/lib/libXfont2/configure
index a5a894d08..04b59564f 100755
--- a/lib/libXfont2/configure
+++ b/lib/libXfont2/configure
@@ -1,8 +1,8 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for libXfont2 2.0.3.
+# Generated by GNU Autoconf 2.69 for libXfont2 2.0.4.
#
-# Report bugs to <https://bugs.freedesktop.org/enter_bug.cgi?product=xorg>.
+# Report bugs to <https://gitlab.freedesktop.org/xorg/lib/libXfont/issues>.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -275,7 +275,7 @@ fi
$as_echo "$0: be upgraded to zsh 4.3.4 or later."
else
$as_echo "$0: Please tell bug-autoconf@gnu.org and
-$0: https://bugs.freedesktop.org/enter_bug.cgi?product=xorg
+$0: https://gitlab.freedesktop.org/xorg/lib/libXfont/issues
$0: about your system, including any error possibly output
$0: before this message. Then install a modern shell, or
$0: manually run the script under such a shell if you do
@@ -651,9 +651,9 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='libXfont2'
PACKAGE_TARNAME='libXfont2'
-PACKAGE_VERSION='2.0.3'
-PACKAGE_STRING='libXfont2 2.0.3'
-PACKAGE_BUGREPORT='https://bugs.freedesktop.org/enter_bug.cgi?product=xorg'
+PACKAGE_VERSION='2.0.4'
+PACKAGE_STRING='libXfont2 2.0.4'
+PACKAGE_BUGREPORT='https://gitlab.freedesktop.org/xorg/lib/libXfont/issues'
PACKAGE_URL=''
ac_unique_file="Makefile.am"
@@ -693,10 +693,10 @@ ac_includes_default="\
# include <unistd.h>
#endif"
+ac_config_libobj_dir=src/util
ac_subst_vars='am__EXEEXT_FALSE
am__EXEEXT_TRUE
LTLIBOBJS
-LIBOBJS
OS_CFLAGS
XFONT_LIBS
XFONT_CFLAGS
@@ -727,6 +727,7 @@ FREETYPE_LIBS
FREETYPE_CFLAGS
XFONT_FREETYPE_FALSE
XFONT_FREETYPE_TRUE
+LIBOBJS
HAVE_STYLESHEETS_FALSE
HAVE_STYLESHEETS_TRUE
XSL_STYLESHEET
@@ -1468,7 +1469,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures libXfont2 2.0.3 to adapt to many kinds of systems.
+\`configure' configures libXfont2 2.0.4 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1538,7 +1539,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of libXfont2 2.0.3:";;
+ short | recursive ) echo "Configuration of libXfont2 2.0.4:";;
esac
cat <<\_ACEOF
@@ -1624,7 +1625,7 @@ Some influential environment variables:
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
-Report bugs to <https://bugs.freedesktop.org/enter_bug.cgi?product=xorg>.
+Report bugs to <https://gitlab.freedesktop.org/xorg/lib/libXfont/issues>.
_ACEOF
ac_status=$?
fi
@@ -1687,7 +1688,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-libXfont2 configure 2.0.3
+libXfont2 configure 2.0.4
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1847,7 +1848,7 @@ $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
( $as_echo "## ---------------------------------------------------------------------- ##
-## Report this to https://bugs.freedesktop.org/enter_bug.cgi?product=xorg ##
+## Report this to https://gitlab.freedesktop.org/xorg/lib/libXfont/issues ##
## ---------------------------------------------------------------------- ##"
) | sed "s/^/$as_me: WARNING: /" >&2
;;
@@ -2213,7 +2214,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by libXfont2 $as_me 2.0.3, which was
+It was created by libXfont2 $as_me 2.0.4, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -3042,7 +3043,7 @@ fi
# Define the identity of the package.
PACKAGE='libXfont2'
- VERSION='2.0.3'
+ VERSION='2.0.4'
cat >>confdefs.h <<_ACEOF
@@ -17793,10 +17794,11 @@ _ACEOF
-CHANGELOG_CMD="(GIT_DIR=\$(top_srcdir)/.git git log > \$(top_srcdir)/.changelog.tmp && \
+CHANGELOG_CMD="((GIT_DIR=\$(top_srcdir)/.git git log > \$(top_srcdir)/.changelog.tmp) 2>/dev/null && \
mv \$(top_srcdir)/.changelog.tmp \$(top_srcdir)/ChangeLog) \
-|| (rm -f \$(top_srcdir)/.changelog.tmp; touch \$(top_srcdir)/ChangeLog; \
-echo 'git directory not found: installing possibly empty changelog.' >&2)"
+|| (rm -f \$(top_srcdir)/.changelog.tmp; test -e \$(top_srcdir)/ChangeLog || ( \
+touch \$(top_srcdir)/ChangeLog; \
+echo 'git failed to create ChangeLog: installing empty ChangeLog.' >&2))"
@@ -17804,13 +17806,44 @@ echo 'git directory not found: installing possibly empty changelog.' >&2)"
macros_datadir=`$PKG_CONFIG --print-errors --variable=pkgdatadir xorg-macros`
INSTALL_CMD="(cp -f "$macros_datadir/INSTALL" \$(top_srcdir)/.INSTALL.tmp && \
mv \$(top_srcdir)/.INSTALL.tmp \$(top_srcdir)/INSTALL) \
-|| (rm -f \$(top_srcdir)/.INSTALL.tmp; touch \$(top_srcdir)/INSTALL; \
-echo 'util-macros \"pkgdatadir\" from xorg-macros.pc not found: installing possibly empty INSTALL.' >&2)"
+|| (rm -f \$(top_srcdir)/.INSTALL.tmp; test -e \$(top_srcdir)/INSTALL || ( \
+touch \$(top_srcdir)/INSTALL; \
+echo 'failed to copy INSTALL from util-macros: installing empty INSTALL.' >&2))"
+
+
+case $host_os in
+ solaris*)
+ # Solaris 2.0 - 11.3 use SysV man page section numbers, so we
+ # check for a man page file found in later versions that use
+ # traditional section numbers instead
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for /usr/share/man/man7/attributes.7" >&5
+$as_echo_n "checking for /usr/share/man/man7/attributes.7... " >&6; }
+if ${ac_cv_file__usr_share_man_man7_attributes_7+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ test "$cross_compiling" = yes &&
+ as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5
+if test -r "/usr/share/man/man7/attributes.7"; then
+ ac_cv_file__usr_share_man_man7_attributes_7=yes
+else
+ ac_cv_file__usr_share_man_man7_attributes_7=no
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_file__usr_share_man_man7_attributes_7" >&5
+$as_echo "$ac_cv_file__usr_share_man_man7_attributes_7" >&6; }
+if test "x$ac_cv_file__usr_share_man_man7_attributes_7" = xyes; then :
+ SYSV_MAN_SECTIONS=false
+else
+ SYSV_MAN_SECTIONS=true
+fi
+ ;;
+ *) SYSV_MAN_SECTIONS=false ;;
+esac
if test x$APP_MAN_SUFFIX = x ; then
APP_MAN_SUFFIX=1
@@ -17827,9 +17860,9 @@ if test x$LIB_MAN_DIR = x ; then
fi
if test x$FILE_MAN_SUFFIX = x ; then
- case $host_os in
- solaris*) FILE_MAN_SUFFIX=4 ;;
- *) FILE_MAN_SUFFIX=5 ;;
+ case $SYSV_MAN_SECTIONS in
+ true) FILE_MAN_SUFFIX=4 ;;
+ *) FILE_MAN_SUFFIX=5 ;;
esac
fi
if test x$FILE_MAN_DIR = x ; then
@@ -17837,9 +17870,9 @@ if test x$FILE_MAN_DIR = x ; then
fi
if test x$MISC_MAN_SUFFIX = x ; then
- case $host_os in
- solaris*) MISC_MAN_SUFFIX=5 ;;
- *) MISC_MAN_SUFFIX=7 ;;
+ case $SYSV_MAN_SECTIONS in
+ true) MISC_MAN_SUFFIX=5 ;;
+ *) MISC_MAN_SUFFIX=7 ;;
esac
fi
if test x$MISC_MAN_DIR = x ; then
@@ -17847,9 +17880,9 @@ if test x$MISC_MAN_DIR = x ; then
fi
if test x$DRIVER_MAN_SUFFIX = x ; then
- case $host_os in
- solaris*) DRIVER_MAN_SUFFIX=7 ;;
- *) DRIVER_MAN_SUFFIX=4 ;;
+ case $SYSV_MAN_SECTIONS in
+ true) DRIVER_MAN_SUFFIX=7 ;;
+ *) DRIVER_MAN_SUFFIX=4 ;;
esac
fi
if test x$DRIVER_MAN_DIR = x ; then
@@ -17857,9 +17890,9 @@ if test x$DRIVER_MAN_DIR = x ; then
fi
if test x$ADMIN_MAN_SUFFIX = x ; then
- case $host_os in
- solaris*) ADMIN_MAN_SUFFIX=1m ;;
- *) ADMIN_MAN_SUFFIX=8 ;;
+ case $SYSV_MAN_SECTIONS in
+ true) ADMIN_MAN_SUFFIX=1m ;;
+ *) ADMIN_MAN_SUFFIX=8 ;;
esac
fi
if test x$ADMIN_MAN_DIR = x ; then
@@ -18107,6 +18140,11 @@ esac
fi
# Test for the ability of xmlto to generate a text target
+#
+# NOTE: xmlto 0.0.27 or higher return a non-zero return code in the
+# following test for empty XML docbook files.
+# For compatibility reasons use the following empty XML docbook file and if
+# it fails try it again with a non-empty XML file.
have_xmlto_text=no
cat > conftest.xml << "EOF"
EOF
@@ -18114,10 +18152,18 @@ if test "$have_xmlto" = yes; then :
if $XMLTO --skip-validation txt conftest.xml >/dev/null 2>&1; then :
have_xmlto_text=yes
else
+ # Try it again with a non-empty XML file.
+ cat > conftest.xml << "EOF"
+<x></x>
+EOF
+ if $XMLTO --skip-validation txt conftest.xml >/dev/null 2>&1; then :
+ have_xmlto_text=yes
+else
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: xmlto cannot generate text format, this format skipped" >&5
$as_echo "$as_me: WARNING: xmlto cannot generate text format, this format skipped" >&2;}
fi
fi
+fi
rm -f conftest.xml
if test $have_xmlto_text = yes; then
HAVE_XMLTO_TEXT_TRUE=
@@ -18332,6 +18378,103 @@ _ACEOF
fi
done
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing strlcat" >&5
+$as_echo_n "checking for library containing strlcat... " >&6; }
+if ${ac_cv_search_strlcat+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char strlcat ();
+int
+main ()
+{
+return strlcat ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' bsd; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_search_strlcat=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+ if ${ac_cv_search_strlcat+:} false; then :
+ break
+fi
+done
+if ${ac_cv_search_strlcat+:} false; then :
+
+else
+ ac_cv_search_strlcat=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_strlcat" >&5
+$as_echo "$ac_cv_search_strlcat" >&6; }
+ac_res=$ac_cv_search_strlcat
+if test "$ac_res" != no; then :
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+
+ac_fn_c_check_func "$LINENO" "reallocarray" "ac_cv_func_reallocarray"
+if test "x$ac_cv_func_reallocarray" = xyes; then :
+ $as_echo "#define HAVE_REALLOCARRAY 1" >>confdefs.h
+
+else
+ case " $LIBOBJS " in
+ *" reallocarray.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS reallocarray.$ac_objext"
+ ;;
+esac
+
+fi
+
+ac_fn_c_check_func "$LINENO" "strlcat" "ac_cv_func_strlcat"
+if test "x$ac_cv_func_strlcat" = xyes; then :
+ $as_echo "#define HAVE_STRLCAT 1" >>confdefs.h
+
+else
+ case " $LIBOBJS " in
+ *" strlcat.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS strlcat.$ac_objext"
+ ;;
+esac
+
+fi
+
+ac_fn_c_check_func "$LINENO" "strlcpy" "ac_cv_func_strlcpy"
+if test "x$ac_cv_func_strlcpy" = xyes; then :
+ $as_echo "#define HAVE_STRLCPY 1" >>confdefs.h
+
+else
+ case " $LIBOBJS " in
+ *" strlcpy.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS strlcpy.$ac_objext"
+ ;;
+esac
+
+fi
+
+
# If the first PKG_CHECK_MODULES appears inside a conditional, pkg-config
# must first be located explicitly.
@@ -19362,6 +19505,20 @@ $as_echo "#define LOCALCONN 1" >>confdefs.h
fi
+ # Other functions Xtrans may need
+ for ac_func in strcasecmp strlcpy
+do :
+ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
case $host_os in
@@ -19990,7 +20147,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by libXfont2 $as_me 2.0.3, which was
+This file was extended by libXfont2 $as_me 2.0.4, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -20050,13 +20207,13 @@ $config_headers
Configuration commands:
$config_commands
-Report bugs to <https://bugs.freedesktop.org/enter_bug.cgi?product=xorg>."
+Report bugs to <https://gitlab.freedesktop.org/xorg/lib/libXfont/issues>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-libXfont2 config.status 2.0.3
+libXfont2 config.status 2.0.4
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/lib/libXfont2/configure.ac b/lib/libXfont2/configure.ac
index f3b4a7aa5..f507c285a 100644
--- a/lib/libXfont2/configure.ac
+++ b/lib/libXfont2/configure.ac
@@ -21,8 +21,8 @@
# Initialize Autoconf
AC_PREREQ([2.60])
-AC_INIT([libXfont2], [2.0.3],
- [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libXfont2])
+AC_INIT([libXfont2], [2.0.4],
+ [https://gitlab.freedesktop.org/xorg/lib/libXfont/issues], [libXfont2])
AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_HEADERS([config.h])
@@ -52,6 +52,9 @@ AC_CHECK_HEADERS([endian.h poll.h sys/poll.h])
# Checks for library functions.
AC_CHECK_FUNCS([poll readlink])
+AC_SEARCH_LIBS([strlcat], [bsd])
+AC_CONFIG_LIBOBJ_DIR([src/util])
+AC_REPLACE_FUNCS([reallocarray strlcat strlcpy])
# If the first PKG_CHECK_MODULES appears inside a conditional, pkg-config
# must first be located explicitly.
diff --git a/lib/libXfont2/include/X11/fonts/fntfil.h b/lib/libXfont2/include/X11/fonts/fntfil.h
index 24be79a66..473474b46 100644
--- a/lib/libXfont2/include/X11/fonts/fntfil.h
+++ b/lib/libXfont2/include/X11/fonts/fntfil.h
@@ -42,7 +42,6 @@ typedef struct _FontScalableEntry *FontScalableEntryPtr;
typedef struct _FontScaleAliasEntry *FontScaleAliasEntryPtr;
typedef struct _FontBitmapEntry *FontBitmapEntryPtr;
typedef struct _FontAliasEntry *FontAliasEntryPtr;
-typedef struct _FontBCEntry *FontBCEntryPtr;
typedef struct _FontDirectory *FontDirectoryPtr;
typedef struct _FontRenderer *FontRendererPtr;
@@ -55,7 +54,6 @@ typedef struct _FontRenderer *FontRendererPtr;
#define NullFontScaleAliasEntry ((FontScaleAliasEntry) 0)
#define NullFontBitmapEntry ((FontBitmapEntry) 0)
#define NullFontAliasEntry ((FontAliasEntry) 0)
-#define NullFontBCEntry ((FontBCEntry) 0)
#define NullFontDirectory ((FontDirectoryPtr) 0)
#define NullFontRenderer ((FontRendererPtr) 0)
@@ -63,7 +61,6 @@ typedef struct _FontRenderer *FontRendererPtr;
#define FONT_ENTRY_SCALE_ALIAS 1
#define FONT_ENTRY_BITMAP 2
#define FONT_ENTRY_ALIAS 3
-#define FONT_ENTRY_BC 4
#define MAXFONTNAMELEN 1024
#define MAXFONTFILENAMELEN 1024
diff --git a/lib/libXfont2/include/X11/fonts/fntfilst.h b/lib/libXfont2/include/X11/fonts/fntfilst.h
index 6e8645e16..e5a59e569 100644
--- a/lib/libXfont2/include/X11/fonts/fntfilst.h
+++ b/lib/libXfont2/include/X11/fonts/fntfilst.h
@@ -85,11 +85,6 @@ typedef struct _FontAliasEntry {
char *resolved;
} FontAliasEntryRec;
-typedef struct _FontBCEntry {
- FontScalableRec vals;
- FontEntryPtr entry;
-} FontBCEntryRec;
-
typedef struct _FontEntry {
FontNameRec name;
int type;
@@ -97,7 +92,6 @@ typedef struct _FontEntry {
FontScalableEntryRec scalable;
FontBitmapEntryRec bitmap;
FontAliasEntryRec alias;
- FontBCEntryRec bc;
} u;
} FontEntryRec;
diff --git a/lib/libXfont2/src/FreeType/ftenc.c b/lib/libXfont2/src/FreeType/ftenc.c
index dfa5cab22..5b0299345 100644
--- a/lib/libXfont2/src/FreeType/ftenc.c
+++ b/lib/libXfont2/src/FreeType/ftenc.c
@@ -90,9 +90,7 @@ FTPickMapping(char *xlfd, int length, char *filename, FT_Face face,
currently only work for BDFs. */
if(strlen(enc) + strlen(reg) > 18)
goto native;
- strcpy(buf, enc);
- strcat(buf, "-");
- strcat(buf, reg);
+ snprintf(buf, sizeof(buf), "%s-%s", enc, reg);
ErrorF("%s %s\n", buf, encoding_name);
if(strcasecmp(buf, "iso10646-1") != 0) {
if(strcasecmp(buf, encoding_name) == 0)
diff --git a/lib/libXfont2/src/FreeType/ftfuncs.c b/lib/libXfont2/src/FreeType/ftfuncs.c
index e7c802648..e98f920e0 100644
--- a/lib/libXfont2/src/FreeType/ftfuncs.c
+++ b/lib/libXfont2/src/FreeType/ftfuncs.c
@@ -31,6 +31,7 @@ THE SOFTWARE.
#endif
#include "libxfontint.h"
#include <X11/fonts/fontmisc.h>
+#include "src/util/replace.h"
#include <string.h>
#include <math.h>
@@ -636,7 +637,7 @@ FreeTypeInstanceFindGlyph(unsigned idx_in, int flags, FTInstancePtr instance,
}
if((*glyphs)[segment] == NULL) {
- (*glyphs)[segment] = malloc(sizeof(CharInfoRec) * FONTSEGMENTSIZE);
+ (*glyphs)[segment] = mallocarray(sizeof(CharInfoRec), FONTSEGMENTSIZE);
if((*glyphs)[segment] == NULL)
return AllocError;
}
@@ -1604,7 +1605,7 @@ FreeTypeAddProperties(FTFontPtr font, FontScalablePtr vals, FontInfoPtr info,
info->nprops = 0; /* in case we abort */
- strcpy(val, fontname);
+ strlcpy(val, fontname, sizeof(val));
if(FontParseXLFDName(val, vals, FONT_XLFD_REPLACE_VALUE)) {
xlfdProps = 1;
} else {
@@ -1622,7 +1623,7 @@ FreeTypeAddProperties(FTFontPtr font, FontScalablePtr vals, FontInfoPtr info,
( (font_properties && (post || t1info)) ? 3 : 0 ) +
2; /* type */
- info->props = malloc(maxprops * sizeof(FontPropRec));
+ info->props = mallocarray(maxprops, sizeof(FontPropRec));
if(info->props == NULL)
return AllocError;
@@ -2123,7 +2124,7 @@ restrict_code_range_by_str(int count,unsigned short *refFirstCol,
#endif
nRanges++;
oldRanges = ranges;
- ranges = realloc(ranges, nRanges*sizeof(*ranges));
+ ranges = reallocarray(ranges, nRanges, sizeof(*ranges));
if (NULL == ranges) {
free(oldRanges);
break;
@@ -2199,15 +2200,16 @@ FreeTypeSetUpTTCap( char *fileName, FontScalablePtr vals,
/* colon exist in the right side of slash. */
int dirLen = p1-fileName;
int baseLen = fileName+len - p2 -1;
+ int fullLen = dirLen+baseLen+1;
- *dynStrRealFileName = malloc(dirLen+baseLen+1);
+ *dynStrRealFileName = malloc(fullLen);
if( *dynStrRealFileName == NULL ) {
result = AllocError;
goto quit;
}
if ( 0 < dirLen )
memcpy(*dynStrRealFileName, fileName, dirLen);
- strcpy(*dynStrRealFileName+dirLen, p2+1);
+ strlcpy(*dynStrRealFileName+dirLen, p2+1, fullLen - dirLen);
capHead = p1;
} else {
*dynStrRealFileName = strdup(fileName);
@@ -2269,8 +2271,9 @@ FreeTypeSetUpTTCap( char *fileName, FontScalablePtr vals,
}
if( beginptr && 0 < *face_number ) {
char *slash;
- *dynStrFTFileName = /* add -> ':'+strlen0+':'+strlen1+'\0' */
- malloc(1+strlen(beginptr)+1+strlen(*dynStrRealFileName)+1);
+ size_t dsftlen = /* add -> ':'+strlen0+':'+strlen1+'\0' */
+ 1 + strlen(beginptr) + 1 + strlen(*dynStrRealFileName) + 1;
+ *dynStrFTFileName = malloc(dsftlen);
if( *dynStrFTFileName == NULL ){
result = AllocError;
goto quit;
@@ -2279,19 +2282,19 @@ FreeTypeSetUpTTCap( char *fileName, FontScalablePtr vals,
slash = strrchr(*dynStrRealFileName,'/');
if( slash ) {
char *p;
- strcat(*dynStrFTFileName,*dynStrRealFileName);
+ strlcat(*dynStrFTFileName, *dynStrRealFileName, dsftlen);
p = strrchr(*dynStrFTFileName,'/');
p[1] = '\0';
- strcat(*dynStrFTFileName,":");
- strcat(*dynStrFTFileName,beginptr);
- strcat(*dynStrFTFileName,":");
- strcat(*dynStrFTFileName,slash+1);
+ strlcat(*dynStrFTFileName, ":", dsftlen);
+ strlcat(*dynStrFTFileName, beginptr, dsftlen);
+ strlcat(*dynStrFTFileName, ":", dsftlen);
+ strlcat(*dynStrFTFileName, slash+1, dsftlen);
}
else{
- strcat(*dynStrFTFileName,":");
- strcat(*dynStrFTFileName,beginptr);
- strcat(*dynStrFTFileName,":");
- strcat(*dynStrFTFileName,*dynStrRealFileName);
+ strlcat(*dynStrFTFileName, ":", dsftlen);
+ strlcat(*dynStrFTFileName, beginptr, dsftlen);
+ strlcat(*dynStrFTFileName, ":", dsftlen);
+ strlcat(*dynStrFTFileName, *dynStrRealFileName, dsftlen);
}
}
else{
@@ -2813,7 +2816,7 @@ FreeTypeLoadFont(FTFontPtr font, FontInfoPtr info, FTFacePtr face,
font->nranges = vals->nranges;
font->ranges = 0;
if(font->nranges) {
- font->ranges = malloc(vals->nranges*sizeof(fsRange));
+ font->ranges = mallocarray(vals->nranges, sizeof(fsRange));
if(font->ranges == NULL)
return AllocError;
memcpy((char*)font->ranges, (char*)vals->ranges,
diff --git a/lib/libXfont2/src/bitmap/bdfread.c b/lib/libXfont2/src/bitmap/bdfread.c
index f2b1e2238..f4340b93c 100644
--- a/lib/libXfont2/src/bitmap/bdfread.c
+++ b/lib/libXfont2/src/bitmap/bdfread.c
@@ -53,6 +53,7 @@ from The Open Group.
#include <config.h>
#endif
#include "libxfontint.h"
+#include "src/util/replace.h"
#include <ctype.h>
#include <X11/fonts/fntfilst.h>
@@ -107,7 +108,7 @@ bdfReadBitmap(CharInfoPtr pCI, FontFilePtr file, int bit, int byte,
widthBytes = BYTES_PER_ROW(widthBits, glyph);
if (widthBytes * height > 0) {
- picture = malloc(widthBytes * height);
+ picture = mallocarray(widthBytes, height);
if (!picture) {
bdfError("Couldn't allocate picture (%d*%d)\n", widthBytes, height);
goto BAILOUT;
@@ -313,7 +314,7 @@ bdfReadCharacters(FontFilePtr file, FontPtr pFont, bdfFileState *pState,
bitmapFont->metrics = ci;
if (bitmapExtra) {
- bitmapExtra->glyphNames = malloc(nchars * sizeof(Atom));
+ bitmapExtra->glyphNames = mallocarray(nchars, sizeof(Atom));
if (!bitmapExtra->glyphNames) {
bdfError("Couldn't allocate glyphNames (%d*%d)\n",
nchars, (int) sizeof(Atom));
@@ -321,7 +322,7 @@ bdfReadCharacters(FontFilePtr file, FontPtr pFont, bdfFileState *pState,
}
}
if (bitmapExtra) {
- bitmapExtra->sWidths = malloc(nchars * sizeof(int));
+ bitmapExtra->sWidths = mallocarray(nchars, sizeof(int));
if (!bitmapExtra->sWidths) {
bdfError("Couldn't allocate sWidth (%d *%d)\n",
nchars, (int) sizeof(int));
@@ -640,7 +641,7 @@ bdfReadProperties(FontFilePtr file, FontPtr pFont, bdfFileState *pState)
pFont->info.props = NULL;
pFont->info.nprops = 0;
- stringProps = malloc((nProps + BDF_GENPROPS) * sizeof(char));
+ stringProps = mallocarray((nProps + BDF_GENPROPS), sizeof(char));
pFont->info.isStringProp = stringProps;
if (stringProps == NULL) {
bdfError("Couldn't allocate stringProps (%d*%d)\n",
diff --git a/lib/libXfont2/src/bitmap/bitmaputil.c b/lib/libXfont2/src/bitmap/bitmaputil.c
index 232729ffb..c2135a068 100644
--- a/lib/libXfont2/src/bitmap/bitmaputil.c
+++ b/lib/libXfont2/src/bitmap/bitmaputil.c
@@ -30,6 +30,7 @@ from The Open Group.
#include <config.h>
#endif
#include "libxfontint.h"
+#include "src/util/replace.h"
#include <X11/fonts/fntfilst.h>
#include <X11/fonts/bitmap.h>
@@ -210,7 +211,7 @@ bitmapAddInkMetrics(FontPtr pFont)
int i;
bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
- bitmapFont->ink_metrics = malloc(bitmapFont->num_chars * sizeof(xCharInfo));
+ bitmapFont->ink_metrics = mallocarray(bitmapFont->num_chars, sizeof(xCharInfo));
if (!bitmapFont->ink_metrics) {
fprintf(stderr, "Error: Couldn't allocate ink_metrics (%d*%ld)\n",
bitmapFont->num_chars, (unsigned long)sizeof(xCharInfo));
diff --git a/lib/libXfont2/src/bitmap/bitscale.c b/lib/libXfont2/src/bitmap/bitscale.c
index 00adcc6b0..e29ba9694 100644
--- a/lib/libXfont2/src/bitmap/bitscale.c
+++ b/lib/libXfont2/src/bitmap/bitscale.c
@@ -34,6 +34,7 @@ from The Open Group.
#include <config.h>
#endif
#include "libxfontint.h"
+#include "src/util/replace.h"
#include <X11/fonts/fntfilst.h>
#include <X11/fonts/bitmap.h>
@@ -585,7 +586,7 @@ ComputeScaledProperties(FontInfoPtr sourceFontInfo, /* the font to be scaled */
}
nProps = NPROPS + 1 + sizeof(fontPropTable) / sizeof(fontProp) +
sizeof(rawFontPropTable) / sizeof(fontProp);
- fp = malloc(sizeof(FontPropRec) * nProps);
+ fp = mallocarray(sizeof(FontPropRec), nProps);
*pProps = fp;
if (!fp) {
fprintf(stderr, "Error: Couldn't allocate font properties (%ld*%d)\n",
@@ -596,7 +597,7 @@ ComputeScaledProperties(FontInfoPtr sourceFontInfo, /* the font to be scaled */
*pIsStringProp = isStringProp;
if (!isStringProp)
{
- fprintf(stderr, "Error: Couldn't allocate isStringProp (%d)\n", nProps);
+ fprintf(stderr, "Error: Couldn't allocate isStringProp (%d)\n", nProps);
free (fp);
return 1;
}
@@ -615,8 +616,10 @@ ComputeScaledProperties(FontInfoPtr sourceFontInfo, /* the font to be scaled */
*isStringProp = 0;
switch (fpt->type) {
case atom:
- fp->value = MakeAtom(ptr1, ptr2 - ptr1, TRUE);
- *isStringProp = 1;
+ if ((ptr1 != NULL) && (ptr2 != NULL)) {
+ fp->value = MakeAtom(ptr1, ptr2 - ptr1, TRUE);
+ *isStringProp = 1;
+ }
break;
case truncate_atom:
for (ptr3 = ptr1; *ptr3; ptr3++)
@@ -859,7 +862,7 @@ ScaleFont(FontPtr opf, /* originating font */
bitmapFont->encoding = 0;
bitmapFont->bitmapExtra = 0;
bitmapFont->pDefault = 0;
- bitmapFont->metrics = malloc(nchars * sizeof(CharInfoRec));
+ bitmapFont->metrics = mallocarray(nchars, sizeof(CharInfoRec));
if (!bitmapFont->metrics) {
fprintf(stderr, "Error: Couldn't allocate metrics (%d*%ld)\n",
nchars, (unsigned long)sizeof(CharInfoRec));
@@ -1174,7 +1177,7 @@ ScaleBitmap(FontPtr pFont, CharInfoPtr opci, CharInfoPtr pci,
/* Looks like we need to anti-alias. Create a workspace to
contain the grayscale character plus an additional row and
column for scratch */
- char_grayscale = malloc((width + 1) * (height + 1));
+ char_grayscale = mallocarray((width + 1), (height + 1));
if (char_grayscale)
{
diffusion_workspace = calloc((newWidth + 2) * 2, sizeof(int));
@@ -1596,7 +1599,7 @@ BitmapOpenScalable (FontPathElementPtr fpe,
/* Prepare font properties for the new font */
- strcpy (fontName, scaleFrom->name.name);
+ strlcpy (fontName, scaleFrom->name.name, sizeof(fontName));
FontParseXLFDName (fontName, vals, FONT_XLFD_REPLACE_VALUE);
propCount = ComputeScaledProperties(&sourceFont->info, fontName, vals,
diff --git a/lib/libXfont2/src/bitmap/pcfread.c b/lib/libXfont2/src/bitmap/pcfread.c
index ae34c28ce..bf64d6f0b 100644
--- a/lib/libXfont2/src/bitmap/pcfread.c
+++ b/lib/libXfont2/src/bitmap/pcfread.c
@@ -34,6 +34,7 @@ from The Open Group.
#include <config.h>
#endif
#include "libxfontint.h"
+#include "src/util/replace.h"
#include <X11/fonts/fntfilst.h>
#include <X11/fonts/bitmap.h>
@@ -138,7 +139,7 @@ pcfReadTOC(FontFilePtr file, int *countp)
pcfError("pcfReadTOC(): invalid file format\n");
return NULL;
}
- tables = malloc(count * sizeof(PCFTableRec));
+ tables = mallocarray(count, sizeof(PCFTableRec));
if (!tables) {
pcfError("pcfReadTOC(): Couldn't allocate tables (%d*%d)\n",
count, (int) sizeof(PCFTableRec));
@@ -263,13 +264,13 @@ pcfGetProperties(FontInfoPtr pFontInfo, FontFilePtr file,
goto Bail;
}
if (IS_EOF(file)) goto Bail;
- props = malloc(nprops * sizeof(FontPropRec));
+ props = mallocarray(nprops, sizeof(FontPropRec));
if (!props) {
pcfError("pcfGetProperties(): Couldn't allocate props (%d*%d)\n",
nprops, (int) sizeof(FontPropRec));
goto Bail;
}
- isStringProp = malloc(nprops * sizeof(char));
+ isStringProp = mallocarray(nprops, sizeof(char));
if (!isStringProp) {
pcfError("pcfGetProperties(): Couldn't allocate isStringProp (%d*%d)\n",
nprops, (int) sizeof(char));
@@ -456,7 +457,7 @@ pcfReadFont(FontPtr pFont, FontFilePtr file,
pcfError("pcfReadFont(): invalid file format\n");
goto Bail;
}
- metrics = malloc(nmetrics * sizeof(CharInfoRec));
+ metrics = mallocarray(nmetrics, sizeof(CharInfoRec));
if (!metrics) {
pcfError("pcfReadFont(): Couldn't allocate metrics (%d*%d)\n",
nmetrics, (int) sizeof(CharInfoRec));
@@ -483,7 +484,7 @@ pcfReadFont(FontPtr pFont, FontFilePtr file,
if (nbitmaps != nmetrics || IS_EOF(file))
goto Bail;
/* nmetrics is already ok, so nbitmap also is */
- offsets = malloc(nbitmaps * sizeof(CARD32));
+ offsets = mallocarray(nbitmaps, sizeof(CARD32));
if (!offsets) {
pcfError("pcfReadFont(): Couldn't allocate offsets (%d*%d)\n",
nbitmaps, (int) sizeof(CARD32));
@@ -573,7 +574,7 @@ pcfReadFont(FontPtr pFont, FontFilePtr file,
if (nink_metrics != nmetrics)
goto Bail;
/* nmetrics already checked */
- ink_metrics = malloc(nink_metrics * sizeof(xCharInfo));
+ ink_metrics = mallocarray(nink_metrics, sizeof(xCharInfo));
if (!ink_metrics) {
pcfError("pcfReadFont(): Couldn't allocate ink_metrics (%d*%d)\n",
nink_metrics, (int) sizeof(xCharInfo));
diff --git a/lib/libXfont2/src/bitmap/pcfwrite.c b/lib/libXfont2/src/bitmap/pcfwrite.c
index 61ae83d0e..de7936c34 100644
--- a/lib/libXfont2/src/bitmap/pcfwrite.c
+++ b/lib/libXfont2/src/bitmap/pcfwrite.c
@@ -34,6 +34,7 @@ from The Open Group.
#include <config.h>
#endif
#include "libxfontint.h"
+#include "src/util/replace.h"
#include <X11/fonts/fntfilst.h>
#include <X11/fonts/bitmap.h>
@@ -235,7 +236,7 @@ pcfWriteFont(FontPtr pFont, FontFilePtr file)
ink_minbounds = &pFont->info.ink_minbounds;
ink_maxbounds = &pFont->info.ink_maxbounds;
}
- offsetProps = malloc(pFont->info.nprops * sizeof(FontPropRec));
+ offsetProps = mallocarray(pFont->info.nprops, sizeof(FontPropRec));
if (!offsetProps) {
pcfError("pcfWriteFont(): Couldn't allocate offsetProps (%d*%d)",
pFont->info.nprops, (int) sizeof(FontPropRec));
diff --git a/lib/libXfont2/src/bitmap/snfread.c b/lib/libXfont2/src/bitmap/snfread.c
index 452b99def..2e94f9c7e 100644
--- a/lib/libXfont2/src/bitmap/snfread.c
+++ b/lib/libXfont2/src/bitmap/snfread.c
@@ -53,6 +53,7 @@ from The Open Group.
#include <config.h>
#endif
#include "libxfontint.h"
+#include "src/util/replace.h"
#include <ctype.h>
#include <X11/fonts/fntfilst.h>
@@ -453,13 +454,13 @@ snfReadFontInfo(FontInfoPtr pFontInfo, FontFilePtr file)
return ret;
snfCopyInfo(&fi, pFontInfo);
- pFontInfo->props = malloc(fi.nProps * sizeof(FontPropRec));
+ pFontInfo->props = mallocarray(fi.nProps, sizeof(FontPropRec));
if (!pFontInfo->props) {
snfError("snfReadFontInfo(): Couldn't allocate props (%d*%d)\n",
fi.nProps, (int) sizeof(FontPropRec));
return AllocError;
}
- pFontInfo->isStringProp = malloc(fi.nProps * sizeof(char));
+ pFontInfo->isStringProp = mallocarray(fi.nProps, sizeof(char));
if (!pFontInfo->isStringProp) {
snfError("snfReadFontInfo(): Couldn't allocate isStringProp (%d*%d)\n",
fi.nProps, (int) sizeof(char));
diff --git a/lib/libXfont2/src/fc/fsconvert.c b/lib/libXfont2/src/fc/fsconvert.c
index 312bacb6d..34230e912 100644
--- a/lib/libXfont2/src/fc/fsconvert.c
+++ b/lib/libXfont2/src/fc/fsconvert.c
@@ -29,6 +29,7 @@
#include <config.h>
#endif
#include "libxfontint.h"
+#include "src/util/replace.h"
#include <X11/X.h>
#include <X11/Xtrans/Xtrans.h>
#include <X11/Xpoll.h>
@@ -107,7 +108,7 @@ _fs_convert_props(fsPropInfo *pi, fsPropOffset *po, pointer pd,
|| nprops > SIZE_MAX/(sizeof(FontPropRec) + sizeof(char)))
return -1;
- dprop = malloc(sizeof(FontPropRec) * nprops + sizeof (char) * nprops);
+ dprop = mallocarray(nprops, sizeof(FontPropRec) + sizeof (char));
if (!dprop)
return -1;
diff --git a/lib/libXfont2/src/fc/fserve.c b/lib/libXfont2/src/fc/fserve.c
index 708fc35ef..2d9c2c231 100644
--- a/lib/libXfont2/src/fc/fserve.c
+++ b/lib/libXfont2/src/fc/fserve.c
@@ -54,6 +54,7 @@ in this Software without prior written authorization from The Open Group.
#include <config.h>
#endif
#include "libxfontint.h"
+#include "src/util/replace.h"
#ifdef WIN32
#define _WILLWINSOCK_
@@ -223,8 +224,8 @@ _fs_add_rep_log (FSFpePtr conn, fsGenericReply *rep)
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)); \
+ fprintf (stderr, "Bad Length for %s Reply: %u %s %d\n", \
+ #name, (unsigned) rep->length, op, LENGTHOF(name));\
} \
} while (0)
@@ -933,8 +934,8 @@ fs_read_query_info(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
ret = -1;
#ifdef DEBUG
fprintf(stderr,
- "fsQueryXInfo: bufleft (%ld) / SIZEOF(fsPropOffset) < %d\n",
- bufleft, pi->num_offsets);
+ "fsQueryXInfo: bufleft (%ld) / SIZEOF(fsPropOffset) < %u\n",
+ bufleft, (unsigned) pi->num_offsets);
#endif
goto bail;
}
@@ -947,8 +948,8 @@ fs_read_query_info(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
ret = -1;
#ifdef DEBUG
fprintf(stderr,
- "fsQueryXInfo: bufleft (%ld) < data_len (%d)\n",
- bufleft, pi->data_len);
+ "fsQueryXInfo: bufleft (%ld) < data_len (%u)\n",
+ bufleft, (unsigned) pi->data_len);
#endif
goto bail;
}
@@ -1081,14 +1082,14 @@ fs_read_extent_info(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
/ LENGTHOF(fsXCharInfo))) {
#ifdef DEBUG
fprintf(stderr,
- "fsQueryXExtents16: numExtents (%d) > (%d - %d) / %d\n",
- numExtents, rep->length,
+ "fsQueryXExtents16: numExtents (%d) > (%u - %d) / %d\n",
+ numExtents, (unsigned) rep->length,
LENGTHOF(fsQueryXExtents16Reply), LENGTHOF(fsXCharInfo));
#endif
pCI = NULL;
}
else
- pCI = malloc(sizeof(CharInfoRec) * numInfos);
+ pCI = mallocarray(numInfos, sizeof(CharInfoRec));
if (!pCI)
{
@@ -1957,8 +1958,8 @@ fs_read_glyphs(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
{
#ifdef DEBUG
fprintf(stderr,
- "fsQueryXBitmaps16: num_chars (%d) > bufleft (%ld) / %d\n",
- rep->num_chars, bufleft, SIZEOF (fsOffset32));
+ "fsQueryXBitmaps16: num_chars (%u) > bufleft (%ld) / %d\n",
+ (unsigned) rep->num_chars, bufleft, SIZEOF (fsOffset32));
#endif
err = AllocError;
goto bail;
@@ -1971,8 +1972,8 @@ fs_read_glyphs(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
{
#ifdef DEBUG
fprintf(stderr,
- "fsQueryXBitmaps16: nbytes (%d) > bufleft (%ld)\n",
- rep->nbytes, bufleft);
+ "fsQueryXBitmaps16: nbytes (%u) > bufleft (%ld)\n",
+ (unsigned) rep->nbytes, bufleft);
#endif
err = AllocError;
goto bail;
@@ -2078,7 +2079,8 @@ fs_read_glyphs(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
err = Successful;
bail:
- _fs_done_read (conn, rep->length << 2);
+ if (rep)
+ _fs_done_read (conn, rep->length << 2);
return err;
}
@@ -2573,8 +2575,8 @@ fs_read_list_info(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
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);
+ "fsListFontsWithXInfo: offset length (%u * %d) > bufleft (%ld)\n",
+ (unsigned) pi->num_offsets, (int) SIZEOF (fsPropOffset), bufleft);
#endif
err = AllocError;
goto done;
@@ -2585,8 +2587,8 @@ fs_read_list_info(FontPathElementPtr fpe, FSBlockDataPtr blockrec)
if (pi->data_len > bufleft) {
#ifdef DEBUG
fprintf(stderr,
- "fsListFontsWithXInfo: data length (%d) > bufleft (%ld)\n",
- pi->data_len, bufleft);
+ "fsListFontsWithXInfo: data length (%u) > bufleft (%ld)\n",
+ (unsigned) pi->data_len, bufleft);
#endif
err = AllocError;
goto done;
@@ -3369,8 +3371,9 @@ static FSFpePtr
_fs_init_conn (const char *servername, FontPathElementPtr fpe)
{
FSFpePtr conn;
+ size_t snlen = strlen (servername) + 1;
- conn = calloc (1, sizeof (FSFpeRec) + strlen (servername) + 1);
+ conn = calloc (1, sizeof (FSFpeRec) + snlen);
if (!conn)
return 0;
if (!_fs_io_init (conn))
@@ -3382,7 +3385,7 @@ _fs_init_conn (const char *servername, FontPathElementPtr fpe)
conn->fs_conn_state = FS_CONN_UNCONNECTED;
conn->fs_fd = -1;
conn->fpe = fpe;
- strcpy (conn->servername, servername);
+ strlcpy (conn->servername, servername, snlen);
return conn;
}
diff --git a/lib/libXfont2/src/fontfile/bitsource.c b/lib/libXfont2/src/fontfile/bitsource.c
index 3a6a20f14..8437d4467 100644
--- a/lib/libXfont2/src/fontfile/bitsource.c
+++ b/lib/libXfont2/src/fontfile/bitsource.c
@@ -32,6 +32,7 @@ in this Software without prior written authorization from The Open Group.
#include <config.h>
#endif
#include "libxfontint.h"
+#include "src/util/replace.h"
#include <X11/fonts/fntfilst.h>
BitmapSourcesRec FontFileBitmapSources;
@@ -49,7 +50,7 @@ FontFileRegisterBitmapSource (FontPathElementPtr fpe)
if (FontFileBitmapSources.count == FontFileBitmapSources.size)
{
newsize = FontFileBitmapSources.size + 4;
- new = realloc (FontFileBitmapSources.fpe, newsize * sizeof *new);
+ new = reallocarray (FontFileBitmapSources.fpe, newsize, sizeof *new);
if (!new)
return FALSE;
FontFileBitmapSources.size = newsize;
diff --git a/lib/libXfont2/src/fontfile/catalogue.c b/lib/libXfont2/src/fontfile/catalogue.c
index 208723270..b5c0331d8 100644
--- a/lib/libXfont2/src/fontfile/catalogue.c
+++ b/lib/libXfont2/src/fontfile/catalogue.c
@@ -35,6 +35,7 @@
#include <sys/stat.h>
#include <dirent.h>
#include <unistd.h>
+#include "src/util/replace.h"
static const char CataloguePrefix[] = "catalogue:";
@@ -64,7 +65,8 @@ CatalogueAddFPE (CataloguePtr cat, FontPathElementPtr fpe)
else
cat->fpeAlloc *= 2;
- new = realloc(cat->fpeList, cat->fpeAlloc * sizeof(FontPathElementPtr));
+ new = reallocarray(cat->fpeList, cat->fpeAlloc,
+ sizeof(FontPathElementPtr));
if (new == NULL)
return AllocError;
@@ -149,14 +151,12 @@ CatalogueRescan (FontPathElementPtr fpe, Bool forceScan)
if ((forceScan == FALSE) && (statbuf.st_mtime <= cat->mtime))
return Successful;
+ CatalogueUnrefFPEs (fpe);
+
dir = opendir(path);
if (dir == NULL)
- {
- free(cat);
return BadFontPath;
- }
- CatalogueUnrefFPEs (fpe);
while (entry = readdir(dir), entry != NULL)
{
char *name;
diff --git a/lib/libXfont2/src/fontfile/dirfile.c b/lib/libXfont2/src/fontfile/dirfile.c
index 2802980b0..58ca49171 100644
--- a/lib/libXfont2/src/fontfile/dirfile.c
+++ b/lib/libXfont2/src/fontfile/dirfile.c
@@ -45,6 +45,7 @@ in this Software without prior written authorization from The Open Group.
#include <fcntl.h>
#include <errno.h>
#include <limits.h>
+#include "src/util/replace.h"
static Bool AddFileNameAliases ( FontDirectoryPtr dir );
static int ReadFontAlias ( char *directory, Bool isFile,
@@ -88,12 +89,12 @@ FontFileReadDirectory (const char *directory, FontDirectoryPtr *pdir)
strncpy(dir_path, directory, ptr - directory);
dir_path[ptr - directory] = '\0';
} else {
- strcpy(dir_path, directory);
+ strlcpy(dir_path, directory, sizeof(dir_path));
}
- strcpy(dir_file, dir_path);
+ strlcpy(dir_file, dir_path, sizeof(dir_file));
if (dir_file[strlen(dir_file) - 1] != '/')
- strcat(dir_file, "/");
- strcat(dir_file, FontDirFile);
+ strlcat(dir_file, "/", sizeof(dir_file));
+ strlcat(dir_file, FontDirFile, sizeof(dir_file));
#ifndef WIN32
file_fd = open(dir_file, O_RDONLY | O_NOFOLLOW);
if (file_fd >= 0) {
@@ -124,8 +125,8 @@ FontFileReadDirectory (const char *directory, FontDirectoryPtr *pdir)
}
dir->dir_mtime = statb.st_mtime;
if (format[0] == '\0')
- sprintf(format, "%%%ds %%%d[^\n]\n",
- MAXFONTFILENAMELEN-1, MAXFONTNAMELEN-1);
+ snprintf(format, sizeof(format), "%%%ds %%%d[^\n]\n",
+ MAXFONTFILENAMELEN-1, MAXFONTNAMELEN-1);
while ((count = fscanf(file, format, file_name, font_name)) != EOF) {
#if defined(WIN32)
@@ -176,8 +177,8 @@ FontFileDirectoryChanged(FontDirectoryPtr dir)
if (strlen(dir->directory) + sizeof(FontDirFile) > sizeof(dir_file))
return FALSE;
- strcpy (dir_file, dir->directory);
- strcat (dir_file, FontDirFile);
+ strlcpy (dir_file, dir->directory, sizeof(dir_file));
+ strlcat (dir_file, FontDirFile, sizeof(dir_file));
if (stat (dir_file, &statb) == -1)
{
if (errno != ENOENT || dir->dir_mtime != 0)
@@ -189,8 +190,8 @@ FontFileDirectoryChanged(FontDirectoryPtr dir)
if ((strlen(dir->directory) + sizeof(FontAliasFile)) > sizeof(dir_file))
return FALSE;
- strcpy (dir_file, dir->directory);
- strcat (dir_file, FontAliasFile);
+ strlcpy (dir_file, dir->directory, sizeof(dir_file));
+ strlcat (dir_file, FontAliasFile, sizeof(dir_file));
if (stat (dir_file, &statb) == -1)
{
if (errno != ENOENT || dir->alias_mtime != 0)
@@ -282,13 +283,13 @@ ReadFontAlias(char *directory, Bool isFile, FontDirectoryPtr *pdir)
if (strlen(directory) >= sizeof(alias_file))
return BadFontPath;
dir = *pdir;
- strcpy(alias_file, directory);
+ strlcpy(alias_file, directory, sizeof(alias_file));
if (!isFile) {
if (strlen(directory) + 1 + sizeof(FontAliasFile) > sizeof(alias_file))
return BadFontPath;
if (directory[strlen(directory) - 1] != '/')
- strcat(alias_file, "/");
- strcat(alias_file, FontAliasFile);
+ strlcat(alias_file, "/", sizeof(alias_file));
+ strlcat(alias_file, FontAliasFile, sizeof(alias_file));
}
#ifndef WIN32
@@ -335,7 +336,7 @@ ReadFontAlias(char *directory, Bool isFile, FontDirectoryPtr *pdir)
status = BadFontPath;
break;
}
- strcpy(alias, lexToken);
+ strlcpy(alias, lexToken, sizeof(alias));
token = lexAlias(file, &lexToken);
switch (token) {
case NEWLINE:
diff --git a/lib/libXfont2/src/fontfile/fontdir.c b/lib/libXfont2/src/fontfile/fontdir.c
index 996b7d139..f4edc019f 100644
--- a/lib/libXfont2/src/fontfile/fontdir.c
+++ b/lib/libXfont2/src/fontfile/fontdir.c
@@ -34,6 +34,7 @@ in this Software without prior written authorization from The Open Group.
#include "libxfontint.h"
#include <X11/fonts/fntfilst.h>
#include <X11/keysym.h>
+#include "src/util/replace.h"
#if HAVE_STDINT_H
#include <stdint.h>
@@ -48,7 +49,7 @@ FontFileInitTable (FontTablePtr table, int size)
return FALSE;
if (size)
{
- table->entries = malloc(sizeof(FontEntryRec) * size);
+ table->entries = mallocarray(size, sizeof(FontEntryRec));
if (!table->entries)
return FALSE;
}
@@ -152,11 +153,11 @@ FontFileMakeDir(const char *dirName, int size)
else
dir->attributes = NULL;
strncpy(dir->directory, dirName, dirlen);
- dir->directory[dirlen] = '\0';
- if (dir->attributes)
- strcpy(dir->attributes, attrib);
if (needslash)
- strcat(dir->directory, "/");
+ dir->directory[dirlen] = '/';
+ dir->directory[dirlen + needslash] = '\0';
+ if (dir->attributes)
+ strlcpy(dir->attributes, attrib, attriblen + 1);
return dir;
}
@@ -184,7 +185,7 @@ FontFileAddEntry(FontTablePtr table, FontEntryPtr prototype)
directory that we should just give up before we overflow. */
return NULL;
newsize = table->size + 100;
- entry = realloc(table->entries, newsize * sizeof(FontEntryRec));
+ entry = reallocarray(table->entries, newsize, sizeof(FontEntryRec));
if (!entry)
return (FontEntryPtr)0;
table->size = newsize;
diff --git a/lib/libXfont2/src/fontfile/fontfile.c b/lib/libXfont2/src/fontfile/fontfile.c
index b2f1a6f56..d36bbc03a 100644
--- a/lib/libXfont2/src/fontfile/fontfile.c
+++ b/lib/libXfont2/src/fontfile/fontfile.c
@@ -37,6 +37,7 @@ in this Software without prior written authorization from The Open Group.
#ifdef WIN32
#include <ctype.h>
#endif
+#include "src/util/replace.h"
static unsigned char
ISOLatin1ToLower(unsigned char source)
@@ -354,7 +355,7 @@ FontFileOpenFont (pointer client, FontPathElementPtr fpe, Mask flags,
entry = FontFileFindNameInScalableDir (&dir->scalable, &tmpName, &vals);
if (entry)
{
- strcpy(lowerName, entry->name.name);
+ strlcpy(lowerName, entry->name.name, sizeof(lowerName));
tmpName.name = lowerName;
tmpName.length = entry->name.length;
tmpName.ndashes = entry->name.ndashes;
@@ -442,8 +443,8 @@ FontFileOpenFont (pointer client, FontPathElementPtr fpe, Mask flags,
sizeof(fileName)) {
ret = BadFontName;
} else {
- strcpy (fileName, dir->directory);
- strcat (fileName, scalable->fileName);
+ strlcpy (fileName, dir->directory, sizeof(fileName));
+ strlcat (fileName, scalable->fileName, sizeof(fileName));
if (scalable->renderer->OpenScalable) {
ret = (*scalable->renderer->OpenScalable) (fpe, pFont,
flags, entry, fileName, &vals, format, fmask,
@@ -527,8 +528,8 @@ FontFileOpenBitmapNCF (FontPathElementPtr fpe, FontPtr *pFont,
return BadFontName;
if (strlen(dir->directory) + strlen(bitmap->fileName) >= sizeof(fileName))
return BadFontName;
- strcpy (fileName, dir->directory);
- strcat (fileName, bitmap->fileName);
+ strlcpy (fileName, dir->directory, sizeof(fileName));
+ strlcat (fileName, bitmap->fileName, sizeof(fileName));
ret = (*bitmap->renderer->OpenBitmap)
(fpe, pFont, flags, entry, fileName, format, fmask,
non_cachable_font);
@@ -564,8 +565,8 @@ FontFileGetInfoBitmap (FontPathElementPtr fpe, FontInfoPtr pFontInfo,
return BadFontName;
if (strlen(dir->directory) + strlen(bitmap->fileName) >= sizeof(fileName))
return BadFontName;
- strcpy (fileName, dir->directory);
- strcat (fileName, bitmap->fileName);
+ strlcpy (fileName, dir->directory, sizeof(fileName));
+ strlcat (fileName, bitmap->fileName, sizeof(fileName));
ret = (*bitmap->renderer->GetInfoBitmap) (fpe, pFontInfo, entry, fileName);
return ret;
}
@@ -590,7 +591,7 @@ _FontFileAddScalableNames(FontNamesPtr names, FontNamesPtr scaleNames,
{
--*max;
- strcpy (nameChars, scaleNames->names[i]);
+ strlcpy (nameChars, scaleNames->names[i], sizeof(nameChars));
if ((vals->values_supplied & PIXELSIZE_MASK) ||
!(vals->values_supplied & PIXELSIZE_WILDCARD) ||
vals->y == 0)
@@ -713,7 +714,7 @@ _FontFileListFonts (pointer client, FontPathElementPtr fpe,
/* Match XLFD patterns */
- strcpy (zeroChars, lowerChars);
+ strlcpy (zeroChars, lowerChars, sizeof(zeroChars));
if (lowerName.ndashes == 14 &&
FontParseXLFDName (zeroChars, &vals, FONT_XLFD_REPLACE_ZERO))
{
@@ -940,7 +941,7 @@ FontFileListOneFontWithInfo (pointer client, FontPathElementPtr fpe,
entry = FontFileFindNameInScalableDir (&dir->scalable, &tmpName, &vals);
if (entry)
{
- strcpy(lowerName, entry->name.name);
+ strlcpy(lowerName, entry->name.name, sizeof(lowerName));
tmpName.name = lowerName;
tmpName.length = entry->name.length;
tmpName.ndashes = entry->name.ndashes;
@@ -1008,8 +1009,8 @@ FontFileListOneFontWithInfo (pointer client, FontPathElementPtr fpe,
sizeof(fileName)) {
ret = BadFontName;
} else {
- strcpy (fileName, dir->directory);
- strcat (fileName, scalable->fileName);
+ strlcpy (fileName, dir->directory, sizeof(fileName));
+ strlcat (fileName, scalable->fileName, sizeof(fileName));
if (scalable->renderer->GetInfoScalable)
ret = (*scalable->renderer->GetInfoScalable)
(fpe, *pFontInfo, entry, &tmpName, fileName,
diff --git a/lib/libXfont2/src/fontfile/fontscale.c b/lib/libXfont2/src/fontfile/fontscale.c
index bbc8e106d..7fcaba8d3 100644
--- a/lib/libXfont2/src/fontfile/fontscale.c
+++ b/lib/libXfont2/src/fontfile/fontscale.c
@@ -32,6 +32,7 @@ in this Software without prior written authorization from The Open Group.
#include <config.h>
#endif
#include "libxfontint.h"
+#include "src/util/replace.h"
#include <X11/fonts/fntfilst.h>
#include <math.h>
@@ -49,7 +50,7 @@ FontFileAddScaledInstance (FontEntryPtr entry, FontScalablePtr vals,
if (extra->numScaled == extra->sizeScaled)
{
newsize = extra->sizeScaled + 4;
- new = realloc (extra->scaled, newsize * sizeof (FontScaledRec));
+ new = reallocarray (extra->scaled, newsize, sizeof (FontScaledRec));
if (!new)
return FALSE;
extra->sizeScaled = newsize;
diff --git a/lib/libXfont2/src/fontfile/renderers.c b/lib/libXfont2/src/fontfile/renderers.c
index d0c406483..a457fb7bb 100644
--- a/lib/libXfont2/src/fontfile/renderers.c
+++ b/lib/libXfont2/src/fontfile/renderers.c
@@ -32,6 +32,7 @@ in this Software without prior written authorization from The Open Group.
#include <config.h>
#endif
#include "libxfontint.h"
+#include "src/util/replace.h"
#include <X11/fonts/fntfilst.h>
static FontRenderersRec renderers;
@@ -80,7 +81,7 @@ FontFilePriorityRegisterRenderer (FontRendererPtr renderer, int priority)
}
if(i >= renderers.number) {
- new = realloc (renderers.renderers, sizeof(*new) * (i + 1));
+ new = reallocarray (renderers.renderers, i + 1, sizeof(*new));
if (!new)
return FALSE;
renderers.renderers = new;
diff --git a/lib/libXfont2/src/stubs/atom.c b/lib/libXfont2/src/stubs/atom.c
index 82c8ca3bb..afc186c41 100644
--- a/lib/libXfont2/src/stubs/atom.c
+++ b/lib/libXfont2/src/stubs/atom.c
@@ -34,6 +34,7 @@
#include <config.h>
#endif
#include "libxfontint.h"
+#include "src/util/replace.h"
#include <X11/fonts/fontmisc.h>
typedef struct _AtomList {
@@ -122,7 +123,7 @@ ResizeReverseMap(void)
newMapSize = 1000;
else
newMapSize = reverseMapSize * 2;
- newMap = realloc(reverseMap, newMapSize * sizeof(AtomListPtr));
+ newMap = reallocarray(reverseMap, newMapSize, sizeof(AtomListPtr));
if (newMap == NULL) {
fprintf(stderr, "ResizeReverseMap(): Error: Couldn't reallocate"
" reverseMap (%ld)\n",
@@ -188,7 +189,9 @@ __libxfont_internal__MakeAtom(const char *string, unsigned len, int makeit)
a->atom = ++lastAtom;
a->hash = hash;
if (hashUsed >= hashSize / 2) {
- ResizeHashTable();
+ if ((ResizeHashTable() == FALSE) &&
+ ((hashTable == NULL) || (hashUsed == hashSize)))
+ return None;
h = hash & hashMask;
if (hashTable[h]) {
r = (hash % rehash) | 1;
diff --git a/lib/libXfont2/src/util/fontnames.c b/lib/libXfont2/src/util/fontnames.c
index b29248060..43eafc279 100644
--- a/lib/libXfont2/src/util/fontnames.c
+++ b/lib/libXfont2/src/util/fontnames.c
@@ -35,6 +35,7 @@ from The Open Group.
#include <config.h>
#endif
#include "libxfontint.h"
+#include "src/util/replace.h"
#include <X11/fonts/fontmisc.h>
#include <X11/fonts/fontstruct.h>
@@ -64,8 +65,8 @@ xfont2_make_font_names_record(unsigned size)
pFN->size = size;
if (size)
{
- pFN->length = malloc(size * sizeof(int));
- pFN->names = malloc(size * sizeof(char *));
+ pFN->length = mallocarray(size, sizeof(int));
+ pFN->names = mallocarray(size, sizeof(char *));
if (!pFN->length || !pFN->names) {
free(pFN->length);
free(pFN->names);
@@ -100,8 +101,8 @@ xfont2_add_font_names_name(FontNamesPtr names,
if (size == 0)
size = 8;
- nlength = realloc(names->length, size * sizeof(int));
- nnames = realloc(names->names, size * sizeof(char *));
+ nlength = reallocarray(names->length, size, sizeof(int));
+ nnames = reallocarray(names->names, size, sizeof(char *));
if (nlength && nnames) {
names->size = size;
names->length = nlength;
diff --git a/lib/libXfont2/src/util/fontutil.c b/lib/libXfont2/src/util/fontutil.c
index d1b845be4..fd87d77cb 100644
--- a/lib/libXfont2/src/util/fontutil.c
+++ b/lib/libXfont2/src/util/fontutil.c
@@ -34,6 +34,7 @@ from The Open Group.
#include <config.h>
#endif
#include "libxfontint.h"
+#include "src/util/replace.h"
#include <X11/fonts/fontmisc.h>
#include <X11/fonts/fontstruct.h>
#include <X11/fonts/FSproto.h>
@@ -136,7 +137,7 @@ xfont2_query_text_extents(FontPtr pFont,
unsigned char defc[2];
int firstReal;
- charinfo = malloc(count * sizeof(xCharInfo *));
+ charinfo = mallocarray(count, sizeof(xCharInfo *));
if (!charinfo)
return FALSE;
encoding = TwoD16Bit;
@@ -302,13 +303,13 @@ add_range(fsRange *newrange,
/* Grow the list if necessary */
if (*nranges == 0 || *range == (fsRange *)0)
{
- *range = malloc(range_alloc_granularity * SIZEOF(fsRange));
+ *range = mallocarray(range_alloc_granularity, SIZEOF(fsRange));
*nranges = 0;
}
else if (!(*nranges % range_alloc_granularity))
{
- *range = realloc(*range, (*nranges + range_alloc_granularity) *
- SIZEOF(fsRange));
+ *range = reallocarray(*range, (*nranges + range_alloc_granularity),
+ SIZEOF(fsRange));
}
/* If alloc failed, just return a null list */
diff --git a/lib/libXfont2/src/util/fontxlfd.c b/lib/libXfont2/src/util/fontxlfd.c
index 0bd1140b7..0a4be1d1d 100644
--- a/lib/libXfont2/src/util/fontxlfd.c
+++ b/lib/libXfont2/src/util/fontxlfd.c
@@ -38,6 +38,7 @@ from The Open Group.
#include <X11/fonts/fontstruct.h>
#include <X11/fonts/fontxlfd.h>
#include <X11/fonts/fontutil.h>
+#include <X11/fonts/fntfilst.h> /* for MAXFONTNAMELEN */
#include <X11/Xos.h>
#include <math.h>
#include <stdlib.h>
@@ -49,6 +50,7 @@ from The Open Group.
#endif
#include <ctype.h>
#include <stdio.h> /* for sprintf() */
+#include "src/util/replace.h"
static char *
GetInt(char *ptr, int *val)
@@ -114,11 +116,14 @@ readreal(char *ptr, double *result)
return (p1 == buffer) ? (char *)0 : (ptr + (p1 - buffer));
}
+#define XLFD_DOUBLE_TO_TEXT_BUF_SIZE 80
+
static char *
xlfd_double_to_text(double value, char *buffer, int space_required)
{
register char *p1;
int ndigits, exponent;
+ const size_t buflen = XLFD_DOUBLE_TO_TEXT_BUF_SIZE;
#ifndef NO_LOCALE
if (!locale)
@@ -137,7 +142,7 @@ xlfd_double_to_text(double value, char *buffer, int space_required)
*buffer++ = ' ';
/* Render the number using printf's idea of formatting */
- sprintf(buffer, "%.*le", XLFD_NDIGITS, value);
+ snprintf(buffer, buflen, "%.*le", XLFD_NDIGITS, value);
/* Find and read the exponent value */
for (p1 = buffer + strlen(buffer);
@@ -154,14 +159,14 @@ xlfd_double_to_text(double value, char *buffer, int space_required)
if (exponent >= XLFD_NDIGITS || ndigits - exponent > XLFD_NDIGITS + 1)
{
/* Scientific */
- sprintf(buffer, "%.*le", ndigits - 1, value);
+ snprintf(buffer, buflen, "%.*le", ndigits - 1, value);
}
else
{
/* Fixed */
ndigits -= exponent + 1;
if (ndigits < 0) ndigits = 0;
- sprintf(buffer, "%.*lf", ndigits, value);
+ snprintf(buffer, buflen, "%.*lf", ndigits, value);
if (exponent < 0)
{
p1 = buffer;
@@ -263,7 +268,7 @@ xlfd_round_double(double x)
char buffer[40];
- sprintf(buffer, "%.*lg", XLFD_NDIGITS, x);
+ snprintf(buffer, sizeof(buffer), "%.*lg", XLFD_NDIGITS, x);
return atof(buffer);
}
}
@@ -347,26 +352,28 @@ GetMatrix(char *ptr, FontScalablePtr vals, int which)
static void
-append_ranges(char *fname, int nranges, fsRange *ranges)
+append_ranges(char *fname, size_t fnamelen, int nranges, fsRange *ranges)
{
if (nranges)
{
int i;
- strcat(fname, "[");
+ strlcat(fname, "[", fnamelen);
for (i = 0; i < nranges && strlen(fname) < 1010; i++)
{
- if (i) strcat(fname, " ");
- sprintf(fname + strlen(fname), "%d",
- minchar(ranges[i]));
+ size_t curlen;
+ if (i) strlcat(fname, " ", fnamelen);
+ curlen = strlen(fname);
+ snprintf(fname + curlen, fnamelen - curlen, "%d",
+ minchar(ranges[i]));
if (ranges[i].min_char_low ==
ranges[i].max_char_low &&
ranges[i].min_char_high ==
ranges[i].max_char_high) continue;
- sprintf(fname + strlen(fname), "_%d",
- maxchar(ranges[i]));
+ snprintf(fname + curlen, fnamelen - curlen, "_%d",
+ maxchar(ranges[i]));
}
- strcat(fname, "]");
+ strlcat(fname, "]", fnamelen);
}
}
@@ -382,6 +389,8 @@ FontParseXLFDName(char *fname, FontScalablePtr vals, int subst)
FontScalableRec tmpvals;
char replaceChar = '0';
char tmpBuf[1024];
+ size_t tlen;
+ size_t fnamelen = MAXFONTNAMELEN; /* assumed for now */
int spacingLen;
int l;
char *p;
@@ -439,8 +448,9 @@ FontParseXLFDName(char *fname, FontScalablePtr vals, int subst)
break;
case FONT_XLFD_REPLACE_STAR:
replaceChar = '*';
+ /* FALLTHROUGH */
case FONT_XLFD_REPLACE_ZERO:
- strcpy(tmpBuf, ptr2);
+ strlcpy(tmpBuf, ptr2, sizeof(tmpBuf));
ptr5 = tmpBuf + (ptr5 - ptr2);
ptr3 = tmpBuf + (ptr3 - ptr2);
ptr2 = tmpBuf;
@@ -472,7 +482,7 @@ FontParseXLFDName(char *fname, FontScalablePtr vals, int subst)
*ptr++ = '-';
}
*ptr++ = replaceChar;
- strcpy(ptr, ptr5);
+ strlcpy(ptr, ptr5, fnamelen - (ptr - fname));
*vals = tmpvals;
break;
case FONT_XLFD_REPLACE_VALUE:
@@ -508,68 +518,82 @@ FontParseXLFDName(char *fname, FontScalablePtr vals, int subst)
p = ptr1 + 1; /* weight field */
l = strchr(p, '-') - p;
- sprintf(tmpBuf, "%*.*s", l, l, p);
+ snprintf(tmpBuf, sizeof(tmpBuf), "%*.*s", l, l, p);
p += l + 1; /* slant field */
l = strchr(p, '-') - p;
- sprintf(tmpBuf + strlen(tmpBuf), "-%*.*s", l, l, p);
+ tlen = strlen(tmpBuf);
+ snprintf(tmpBuf + tlen, sizeof(tmpBuf) - tlen, "-%*.*s", l, l, p);
p += l + 1; /* setwidth_name */
l = strchr(p, '-') - p;
- sprintf(tmpBuf + strlen(tmpBuf), "-%*.*s", l, l, p);
+ tlen = strlen(tmpBuf);
+ snprintf(tmpBuf + tlen, sizeof(tmpBuf) - tlen, "-%*.*s", l, l, p);
p += l + 1; /* add_style_name field */
l = strchr(p, '-') - p;
- sprintf(tmpBuf + strlen(tmpBuf), "-%*.*s", l, l, p);
+ tlen = strlen(tmpBuf);
+ snprintf(tmpBuf + tlen, sizeof(tmpBuf) - tlen, "-%*.*s", l, l, p);
- strcat(tmpBuf, "-");
+ strlcat(tmpBuf, "-", sizeof(tmpBuf));
if ((tmpvals.values_supplied & PIXELSIZE_MASK) == PIXELSIZE_ARRAY)
{
- char buffer[80];
- strcat(tmpBuf, "[");
- strcat(tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix[0],
- buffer, 0));
- strcat(tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix[1],
- buffer, 1));
- strcat(tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix[2],
- buffer, 1));
- strcat(tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix[3],
- buffer, 1));
- strcat(tmpBuf, "]");
+ char buffer[XLFD_DOUBLE_TO_TEXT_BUF_SIZE];
+ strlcat(tmpBuf, "[", sizeof(tmpBuf));
+ strlcat(tmpBuf,
+ xlfd_double_to_text(tmpvals.pixel_matrix[0], buffer, 0),
+ sizeof(tmpBuf));
+ strlcat(tmpBuf,
+ xlfd_double_to_text(tmpvals.pixel_matrix[1], buffer, 1),
+ sizeof(tmpBuf));
+ strlcat(tmpBuf,
+ xlfd_double_to_text(tmpvals.pixel_matrix[2], buffer, 1),
+ sizeof(tmpBuf));
+ strlcat(tmpBuf,
+ xlfd_double_to_text(tmpvals.pixel_matrix[3], buffer, 1),
+ sizeof(tmpBuf));
+ strlcat(tmpBuf, "]", sizeof(tmpBuf));
}
else
{
- sprintf(tmpBuf + strlen(tmpBuf), "%d",
- (int)(tmpvals.pixel_matrix[3] + .5));
+ tlen = strlen(tmpBuf);
+ snprintf(tmpBuf + tlen, sizeof(tmpBuf) - tlen, "%d",
+ (int)(tmpvals.pixel_matrix[3] + .5));
}
- strcat(tmpBuf, "-");
+ strlcat(tmpBuf, "-", sizeof(tmpBuf));
if ((tmpvals.values_supplied & POINTSIZE_MASK) == POINTSIZE_ARRAY)
{
- char buffer[80];
- strcat(tmpBuf, "[");
- strcat(tmpBuf, xlfd_double_to_text(tmpvals.point_matrix[0],
- buffer, 0));
- strcat(tmpBuf, xlfd_double_to_text(tmpvals.point_matrix[1],
- buffer, 1));
- strcat(tmpBuf, xlfd_double_to_text(tmpvals.point_matrix[2],
- buffer, 1));
- strcat(tmpBuf, xlfd_double_to_text(tmpvals.point_matrix[3],
- buffer, 1));
- strcat(tmpBuf, "]");
+ char buffer[XLFD_DOUBLE_TO_TEXT_BUF_SIZE];
+ strlcat(tmpBuf, "[", sizeof(tmpBuf));
+ strlcat(tmpBuf,
+ xlfd_double_to_text(tmpvals.point_matrix[0], buffer, 0),
+ sizeof(tmpBuf));
+ strlcat(tmpBuf,
+ xlfd_double_to_text(tmpvals.point_matrix[1], buffer, 1),
+ sizeof(tmpBuf));
+ strlcat(tmpBuf,
+ xlfd_double_to_text(tmpvals.point_matrix[2], buffer, 1),
+ sizeof(tmpBuf));
+ strlcat(tmpBuf,
+ xlfd_double_to_text(tmpvals.point_matrix[3], buffer, 1),
+ sizeof(tmpBuf));
+ strlcat(tmpBuf, "]", sizeof(tmpBuf));
}
else
{
- sprintf(tmpBuf + strlen(tmpBuf), "%d",
- (int)(tmpvals.point_matrix[3] * 10.0 + .5));
+ tlen = strlen(tmpBuf);
+ snprintf(tmpBuf + tlen, sizeof(tmpBuf) - tlen, "%d",
+ (int)(tmpvals.point_matrix[3] * 10.0 + .5));
}
- sprintf(tmpBuf + strlen(tmpBuf), "-%d-%d%*.*s%d%s",
- tmpvals.x, tmpvals.y,
- spacingLen, spacingLen, ptr3, tmpvals.width, ptr5);
- strcpy(ptr1 + 1, tmpBuf);
+ tlen = strlen(tmpBuf);
+ snprintf(tmpBuf + tlen, sizeof(tmpBuf) - tlen, "-%d-%d%*.*s%d%s",
+ tmpvals.x, tmpvals.y,
+ spacingLen, spacingLen, ptr3, tmpvals.width, ptr5);
+ strlcpy(ptr1 + 1, tmpBuf, fnamelen - (ptr1 - fname));
if ((vals->values_supplied & CHARSUBSET_SPECIFIED) && !vals->nranges)
- strcat(fname, "[]");
+ strlcat(fname, "[]", fnamelen);
else
- append_ranges(fname, vals->nranges, vals->ranges);
+ append_ranges(fname, fnamelen, vals->nranges, vals->ranges);
break;
}
return TRUE;
diff --git a/lib/libXfont2/src/util/private.c b/lib/libXfont2/src/util/private.c
index 92075c25f..b07a757b5 100644
--- a/lib/libXfont2/src/util/private.c
+++ b/lib/libXfont2/src/util/private.c
@@ -32,6 +32,7 @@ in this Software without prior written authorization from The Open Group.
#include <config.h>
#endif
#include "libxfontint.h"
+#include "src/util/replace.h"
#include <X11/fonts/fontmisc.h>
#include <X11/fonts/fontstruct.h>
@@ -84,12 +85,12 @@ xfont2_font_set_private(FontPtr pFont, int n, pointer ptr)
if (n > pFont->maxPrivate) {
if (pFont->devPrivates && pFont->devPrivates != (pointer)(&pFont[1])) {
- new = realloc (pFont->devPrivates, (n + 1) * sizeof (pointer));
+ new = reallocarray (pFont->devPrivates, (n + 1), sizeof (pointer));
if (!new)
return FALSE;
} else {
/* omg realloc */
- new = malloc ((n + 1) * sizeof (pointer));
+ new = reallocarray (NULL, (n + 1), sizeof (pointer));
if (!new)
return FALSE;
if (pFont->devPrivates)
diff --git a/lib/libXfont2/src/util/reallocarray.c b/lib/libXfont2/src/util/reallocarray.c
new file mode 100644
index 000000000..7bc8d4f41
--- /dev/null
+++ b/lib/libXfont2/src/util/reallocarray.c
@@ -0,0 +1,43 @@
+/* $OpenBSD: reallocarray.c,v 1.1 2019/12/14 14:57:44 matthieu Exp $ */
+/*
+ * Copyright (c) 2008 Otto Moerbeek <otto@drijf.net>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <sys/types.h>
+#include <errno.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include "src/util/replace.h"
+
+/*
+ * This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX
+ * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW
+ */
+#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4))
+
+void *
+reallocarray(void *optr, size_t nmemb, size_t size)
+{
+ if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
+ nmemb > 0 && SIZE_MAX / nmemb < size) {
+ errno = ENOMEM;
+ return NULL;
+ }
+ return realloc(optr, size * nmemb);
+}
diff --git a/lib/libXfont2/src/util/replace.h b/lib/libXfont2/src/util/replace.h
new file mode 100644
index 000000000..1a248200e
--- /dev/null
+++ b/lib/libXfont2/src/util/replace.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/* Local replacements for functions found in some, but not all, libc's */
+#ifndef XFONT_REPLACE_H
+#define XFONT_REPLACE_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <X11/Xfuncproto.h>
+
+#include <stdlib.h>
+#if defined(HAVE_LIBBSD) && defined(HAVE_REALLOCARRAY)
+#include <bsd/stdlib.h> /* for reallocarray */
+#endif
+
+#ifndef HAVE_REALLOCARRAY
+extern _X_HIDDEN void *
+reallocarray(void *optr, size_t nmemb, size_t size);
+#endif
+
+#ifndef mallocarray
+#define mallocarray(n, s) reallocarray(NULL, n, s)
+#endif
+
+#include <string.h>
+#if defined(HAVE_LIBBSD) && defined(HAVE_STRLCPY)
+#include <bsd/string.h> /* for strlcpy, strlcat */
+#endif
+
+#ifndef HAVE_STRLCPY
+extern _X_HIDDEN size_t
+strlcpy(char *dst, const char *src, size_t siz);
+extern _X_HIDDEN size_t
+strlcat(char *dst, const char *src, size_t siz);
+#endif
+
+
+#endif /* XFONT_REPLACE_H */
diff --git a/lib/libXfont2/src/util/strlcat.c b/lib/libXfont2/src/util/strlcat.c
new file mode 100644
index 000000000..daa43c979
--- /dev/null
+++ b/lib/libXfont2/src/util/strlcat.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE
+ * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <sys/types.h>
+#include <string.h>
+#include "src/util/replace.h"
+
+/*
+ * Appends src to string dst of size siz (unlike strncat, siz is the
+ * full size of dst, not space left). At most siz-1 characters
+ * will be copied. Always NUL terminates (unless siz <= strlen(dst)).
+ * Returns strlen(src) + MIN(siz, strlen(initial dst)).
+ * If retval >= siz, truncation occurred.
+ */
+size_t
+strlcat(char *dst, const char *src, size_t siz)
+{
+ register char *d = dst;
+ register const char *s = src;
+ register size_t n = siz;
+ size_t dlen;
+
+ /* Find the end of dst and adjust bytes left but don't go past end */
+ while (n-- != 0 && *d != '\0')
+ d++;
+ dlen = d - dst;
+ n = siz - dlen;
+
+ if (n == 0)
+ return (dlen + strlen(s));
+ while (*s != '\0') {
+ if (n != 1) {
+ *d++ = *s;
+ n--;
+ }
+ s++;
+ }
+ *d = '\0';
+
+ return (dlen + (s - src)); /* count does not include NUL */
+}
diff --git a/lib/libXfont2/src/util/strlcpy.c b/lib/libXfont2/src/util/strlcpy.c
new file mode 100644
index 000000000..ec7dd40d7
--- /dev/null
+++ b/lib/libXfont2/src/util/strlcpy.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE
+ * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <sys/types.h>
+#include <string.h>
+#include "src/util/replace.h"
+
+/*
+ * Copy src to string dst of size siz. At most siz-1 characters
+ * will be copied. Always NUL terminates (unless siz == 0).
+ * Returns strlen(src); if retval >= siz, truncation occurred.
+ */
+size_t
+strlcpy(char *dst, const char *src, size_t siz)
+{
+ register char *d = dst;
+ register const char *s = src;
+ register size_t n = siz;
+
+ /* Copy as many bytes as will fit */
+ if (n != 0 && --n != 0) {
+ do {
+ if ((*d++ = *s++) == 0)
+ break;
+ } while (--n != 0);
+ }
+
+ /* Not enough room in dst, add NUL and traverse rest of src */
+ if (n == 0) {
+ if (siz != 0)
+ *d = '\0'; /* NUL-terminate dst */
+ while (*s++);
+ }
+
+ return s - src - 1; /* count does not include NUL */
+}
diff --git a/lib/libXfont2/test/utils/README b/lib/libXfont2/test/utils/README
new file mode 100644
index 000000000..ce093a40f
--- /dev/null
+++ b/lib/libXfont2/test/utils/README
@@ -0,0 +1,18 @@
+This directory contains utilities which can be used for adhoc testing of
+libXfont by developers, and which are hoped to be useful for building up
+automated testing in the future.
+
+They are not intended for distros to package and ship to end users - they
+are not documented, and are full of assert() and fatal err() calls where
+end user software would have error handling.
+
+No promises of interface stability are made for these - they may change at
+any time to allow better testing.
+
+Utilities include:
+
+lsfontdir:
+ Reads & prints the contents of fonts.dir files.
+ Takes a list of font path entries on the command line, uses defaults
+ if none specified.
+ For use with afl fuzzer, you must use afl -f fonts.dir lsfontdir @@
diff --git a/lib/libXfont2/test/utils/font-test-utils.c b/lib/libXfont2/test/utils/font-test-utils.c
new file mode 100644
index 000000000..ff0506117
--- /dev/null
+++ b/lib/libXfont2/test/utils/font-test-utils.c
@@ -0,0 +1,337 @@
+/* Common utility code for interacting with libXfont from test utilities
+ *
+ * Note that this code is designed for test programs, and thus uses assert()
+ * and fatal err() calls in places that real code would do error handling,
+ * since the goal is to catch bugs faster, not help users get past problems.
+ */
+
+/*
+ * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/* Based on code from xorg-server/dix/dixfont.c covered by this notice:
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+ */
+
+#include "font-test-utils.h"
+#include "src/util/replace.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <assert.h>
+#include <err.h>
+#include <X11/X.h>
+
+static unsigned long server_generation;
+static xfont2_fpe_funcs_rec const **fpe_functions;
+static int num_fpe_types;
+
+static int
+test_client_auth_generation(ClientPtr client)
+{
+ err(BadImplementation, "%s called but not yet implemented", __func__);
+}
+
+static Bool
+test_client_signal(ClientPtr client)
+{
+ err(BadImplementation, "%s called but not yet implemented", __func__);
+}
+
+static void
+test_delete_font_client_id(Font id)
+{
+ err(BadImplementation, "%s called but not yet implemented", __func__);
+}
+
+static void _X_ATTRIBUTE_PRINTF(1,0)
+test_verrorf(const char *f, va_list ap)
+{
+ vwarn(f, ap);
+}
+
+static FontPtr
+test_find_old_font(FSID id)
+{
+ err(BadImplementation, "%s called but not yet implemented", __func__);
+}
+
+static FontResolutionPtr
+test_get_client_resolutions(int *num)
+{
+ *num = 0;
+ return NULL;
+}
+
+static int
+test_get_default_point_size(void)
+{
+ return 120;
+}
+
+static Font
+test_get_new_font_client_id(void)
+{
+ err(BadImplementation, "%s called but not yet implemented", __func__);
+}
+
+static uint32_t
+test_get_time_in_millis(void)
+{
+ err(BadImplementation, "%s called but not yet implemented", __func__);
+}
+
+static int
+test_init_fs_handlers(FontPathElementPtr fpe,
+ FontBlockHandlerProcPtr block_handler)
+{
+ err(BadImplementation, "%s called but not yet implemented", __func__);
+}
+
+/* Callback from libXfont when each fpe handler is registered */
+static int
+test_register_fpe_funcs(const xfont2_fpe_funcs_rec *funcs)
+{
+ xfont2_fpe_funcs_rec const **new;
+
+ /* grow the list */
+ new = reallocarray(fpe_functions, (num_fpe_types + 1),
+ sizeof(xfont2_fpe_funcs_ptr));
+ assert (new != NULL);
+ fpe_functions = new;
+
+ fpe_functions[num_fpe_types] = funcs;
+
+ return num_fpe_types++;
+}
+
+static void
+test_remove_fs_handlers(FontPathElementPtr fpe,
+ FontBlockHandlerProcPtr block_handler, Bool all)
+{
+ err(BadImplementation, "%s called but not yet implemented", __func__);
+}
+
+static void *
+test_get_server_client(void)
+{
+ err(BadImplementation, "%s called but not yet implemented", __func__);
+}
+
+static int
+test_set_font_authorizations(char **authorizations, int *authlen, void *client)
+{
+ err(BadImplementation, "%s called but not yet implemented", __func__);
+}
+
+static int
+test_store_font_client_font(FontPtr pfont, Font id)
+{
+ err(BadImplementation, "%s called but not yet implemented", __func__);
+}
+
+static Atom
+test_make_atom(const char *string, unsigned len, int makeit)
+{
+ err(BadImplementation, "%s called but not yet implemented", __func__);
+}
+
+static int
+test_valid_atom(Atom atom)
+{
+ err(BadImplementation, "%s called but not yet implemented", __func__);
+}
+
+static const char *
+test_name_for_atom(Atom atom)
+{
+ err(BadImplementation, "%s called but not yet implemented", __func__);
+}
+
+static unsigned long
+test_get_server_generation(void)
+{
+ return server_generation;
+}
+
+static int
+test_add_fs_fd(int fd, FontFdHandlerProcPtr handler, void *data)
+{
+ err(BadImplementation, "%s called but not yet implemented", __func__);
+}
+
+static void
+test_remove_fs_fd(int fd)
+{
+ err(BadImplementation, "%s called but not yet implemented", __func__);
+}
+
+static void
+test_adjust_fs_wait_for_delay(void *wt, unsigned long newdelay)
+{
+ err(BadImplementation, "%s called but not yet implemented", __func__);
+}
+
+static const xfont2_client_funcs_rec xfont2_client_funcs = {
+ .version = XFONT2_CLIENT_FUNCS_VERSION,
+ .client_auth_generation = test_client_auth_generation,
+ .client_signal = test_client_signal,
+ .delete_font_client_id = test_delete_font_client_id,
+ .verrorf = test_verrorf,
+ .find_old_font = test_find_old_font,
+ .get_client_resolutions = test_get_client_resolutions,
+ .get_default_point_size = test_get_default_point_size,
+ .get_new_font_client_id = test_get_new_font_client_id,
+ .get_time_in_millis = test_get_time_in_millis,
+ .init_fs_handlers = test_init_fs_handlers,
+ .register_fpe_funcs = test_register_fpe_funcs,
+ .remove_fs_handlers = test_remove_fs_handlers,
+ .get_server_client = test_get_server_client,
+ .set_font_authorizations = test_set_font_authorizations,
+ .store_font_client_font = test_store_font_client_font,
+ .make_atom = test_make_atom,
+ .valid_atom = test_valid_atom,
+ .name_for_atom = test_name_for_atom,
+ .get_server_generation = test_get_server_generation,
+ .add_fs_fd = test_add_fs_fd,
+ .remove_fs_fd = test_remove_fs_fd,
+ .adjust_fs_wait_for_delay = test_adjust_fs_wait_for_delay,
+};
+
+
+xfont2_fpe_funcs_rec const **
+init_font_handlers(int *fpe_function_count)
+{
+ server_generation++;
+ xfont2_init(&xfont2_client_funcs);
+ /* make sure our callbacks were called & worked */
+ assert (fpe_functions != NULL);
+ assert (num_fpe_types > 0);
+ *fpe_function_count = num_fpe_types;
+ return fpe_functions;
+}
+
+
+/* does the necessary magic to figure out the fpe type */
+static int
+DetermineFPEType(const char *pathname)
+{
+ int i;
+
+ /* make sure init_font_handlers was called first */
+ assert (num_fpe_types > 0);
+
+ for (i = 0; i < num_fpe_types; i++) {
+ if ((*fpe_functions[i]->name_check) (pathname))
+ return i;
+ }
+ return -1;
+}
+
+
+static const char * const default_fpes[] = {
+ "catalogue:/etc/X11/fontpath.d",
+ "built-ins"
+};
+#define num_default_fpes (sizeof(default_fpes) / sizeof(*default_fpes))
+
+FontPathElementPtr *
+init_font_paths(const char * const *font_paths, int *num_fpes)
+{
+ FontPathElementPtr *fpe_list;
+ int i;
+
+ /* make sure init_font_handlers was called first */
+ assert (num_fpe_types > 0);
+
+ /* Use default if caller didn't supply any */
+ if (*num_fpes == 0) {
+ font_paths = default_fpes;
+ *num_fpes = num_default_fpes;
+ }
+
+ fpe_list = calloc(*num_fpes, sizeof(FontPathElementPtr));
+ assert(fpe_list != NULL);
+
+ for (i = 0; i < *num_fpes; i++) {
+ int result;
+ FontPathElementPtr fpe = calloc(1, sizeof(FontPathElementRec));
+ assert(fpe != NULL);
+
+ fpe->name = strdup(font_paths[i]);
+ assert(fpe->name != NULL);
+ fpe->name_length = strlen(fpe->name);
+ assert(fpe->name_length > 0);
+ /* If path is to fonts.dir file, trim it off and use the full
+ directory path instead. Simplifies testing with afl. */
+ if (fpe->name_length > (int) sizeof("/fonts.dir")) {
+ char *tail = fpe->name + fpe->name_length -
+ (sizeof("/fonts.dir") - 1);
+
+ if (strcmp(tail, "/fonts.dir") == 0) {
+ char *fullpath;
+
+ *tail = '\0';
+ fullpath = realpath(fpe->name, NULL);
+ assert(fullpath != NULL);
+ free(fpe->name);
+ fpe->name = fullpath;
+ fpe->name_length = strlen(fpe->name);
+ assert(fpe->name_length > 0);
+ }
+ }
+ fpe->type = DetermineFPEType(fpe->name);
+ if (fpe->type == -1)
+ err(BadFontPath, "Unable to find handler for font path %s",
+ fpe->name);
+ result = (*fpe_functions[fpe->type]->init_fpe) (fpe);
+ if (result != Successful)
+ err(result, "init_fpe failed for font path %s: error %d",
+ fpe->name, result);
+
+ printf("Initialized font path element #%d: %s\n", i, fpe->name);
+ fpe_list[i] = fpe;
+ }
+ printf("\n");
+
+ return fpe_list;
+}
diff --git a/lib/libXfont2/test/utils/font-test-utils.h b/lib/libXfont2/test/utils/font-test-utils.h
new file mode 100644
index 000000000..254f1b946
--- /dev/null
+++ b/lib/libXfont2/test/utils/font-test-utils.h
@@ -0,0 +1,49 @@
+/* Common utility code for interacting with libXfont from test utilities */
+
+/*
+ * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <X11/Xfuncproto.h>
+#include <X11/fonts/font.h>
+#include <X11/fonts/fontstruct.h>
+#include <X11/fonts/fontmisc.h>
+#include <X11/fonts/libxfont2.h>
+
+/* Returns pointer to array of functions for each type of font_path_entry
+ * handler, and puts count of entries in that array into fpe_function_count.
+ * Must be called before init_font_paths().
+ */
+extern xfont2_fpe_funcs_rec const **init_font_handlers(int *fpe_function_count);
+
+/* Returns pointer to array of FontPathElement structs for each font path
+ * entry passed in. num_fpes must be set to the number of entries in the
+ * font_paths array when called - will be set to the number of entries in
+ * the returned array. May be called with (NULL, 0) to use default font
+ * path of "catalogue:/etc/X11/fontpath.d" & "built-ins".
+ */
+extern FontPathElementPtr *init_font_paths(const char * const *font_paths,
+ int *num_fpes);
diff --git a/lib/libXfont2/test/utils/lsfontdir.c b/lib/libXfont2/test/utils/lsfontdir.c
new file mode 100644
index 000000000..1f4659960
--- /dev/null
+++ b/lib/libXfont2/test/utils/lsfontdir.c
@@ -0,0 +1,74 @@
+/* lsfontdir [<font path entry> ...]
+ *
+ * Lists entries from fonts.dir file in given directory paths.
+ * Defaults to "catalogue:/etc/X11/fontpath.d" & "built-ins" if no paths given.
+ */
+
+/*
+ * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "font-test-utils.h"
+#include <stdio.h>
+#include <assert.h>
+#include <err.h>
+
+int
+main(int argc, char **argv)
+{
+ FontPathElementPtr *fpe_list;
+ xfont2_fpe_funcs_rec const **fpe_functions;
+ int fpe_function_count, fpe_list_count;
+ int i, n;
+
+ fpe_functions = init_font_handlers(&fpe_function_count);
+
+ fpe_list_count = argc - 1;
+ fpe_list = init_font_paths((const char **) argv + 1, &fpe_list_count);
+
+ for (i = 0; i < fpe_list_count; i++) {
+ FontPathElementPtr fpe = fpe_list[i];
+ FontNamesPtr names;
+ const int max_names_count = 8192;
+ const char *pattern = "*";
+ int result;
+
+ /* Don't allocate max size up front to allow testing expansion code */
+ names = xfont2_make_font_names_record(max_names_count / 16);
+ assert(names != NULL);
+
+ result = (*fpe_functions[fpe->type]->list_fonts)
+ (NULL, fpe, pattern, strlen(pattern), max_names_count, names);
+ if (result != Successful)
+ err(result, "list_font failed for font path %s: error %d",
+ fpe->name, result);
+
+ printf("--- %s:\n", fpe->name);
+ for (n = 0 ; n < names->nnames; n++) {
+ printf("%s\n", names->names[n]);
+ }
+
+ xfont2_free_font_names(names);
+ }
+
+ return 0;
+}