[packages/fontconfig] Rel 3. Reject crafted caches with bad charset offsets or value types
arekm
arekm at pld-linux.org
Thu Oct 29 08:33:47 CET 2026
commit d29dbd99395fcb00e13d4adc48fcc4f7dc88a024
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Thu Oct 29 01:42:31 2026 +0100
Rel 3. Reject crafted caches with bad charset offsets or value types
fontconfig-cache-charset-validation.patch | 56 +++++++++++++++++++++++++++++++
fontconfig-cache-type-validation.patch | 28 ++++++++++++++++
fontconfig.spec | 11 +++---
3 files changed, 90 insertions(+), 5 deletions(-)
---
diff --git a/fontconfig.spec b/fontconfig.spec
index 34187a3..3f3d977 100644
--- a/fontconfig.spec
+++ b/fontconfig.spec
@@ -9,7 +9,7 @@ Summary(pl.UTF-8): Narzędzia do konfigurowania fontów
Summary(pt_BR.UTF-8): Ferramentas para configuração e customização do acesso a fontes
Name: fontconfig
Version: 2.18.3
-Release: 2
+Release: 3
Epoch: 1
License: MIT
Group: Libraries
@@ -22,7 +22,9 @@ Source0: https://gitlab.freedesktop.org/api/v4/projects/890/packages/generic/fon
Source1: %{name}-lcd-filter.conf
Patch0: %{name}-bitstream-cyberbit.patch
Patch1: disable-tests.patch
-URL: http://fontconfig.org/
+Patch2: %{name}-cache-charset-validation.patch
+Patch3: %{name}-cache-type-validation.patch
+URL: https://fontconfig.org/
BuildRequires: autoconf >= 2.71
BuildRequires: automake >= 1:1.11
%if %{with doc}
@@ -30,7 +32,6 @@ BuildRequires: docbook-dtd31-sgml
BuildRequires: docbook-dtd41-sgml
BuildRequires: docbook-utils >= 0.6.13-3
%endif
-BuildRequires: ed
BuildRequires: expat-devel
# pkgconfig(freetype) >= 21.0.15
BuildRequires: freetype-devel >= 1:2.9
@@ -38,7 +39,6 @@ BuildRequires: gettext-tools >= 0.19.8
BuildRequires: gperf
%{?with_tests:BuildRequires: json-c-devel}
BuildRequires: libtool >= 2:2.2
-BuildRequires: libuuid-devel
BuildRequires: pkgconfig
%{?with_doc:BuildRequires: python3}
BuildRequires: rpmbuild(macros) >= 2.036
@@ -95,7 +95,6 @@ Group: Development/Libraries
Requires: %{name}-libs%{?_isa} = %{epoch}:%{version}-%{release}
Requires: expat-devel%{?_isa}
Requires: freetype-devel%{?_isa} >= 1:2.9
-Requires: libuuid-devel%{?_isa}
Provides: XFree86-fontconfig-devel
Obsoletes: XFree86-fontconfig-devel < 4.4
@@ -142,6 +141,8 @@ Este pacote contém a biblioteca estática do fontconfig
%setup -q
%patch -P0 -p1
%patch -P1 -p1
+%patch -P2 -p1
+%patch -P3 -p1
%build
%{__gettextize -d po-conf}
diff --git a/fontconfig-cache-charset-validation.patch b/fontconfig-cache-charset-validation.patch
new file mode 100644
index 0000000..fc620d9
--- /dev/null
+++ b/fontconfig-cache-charset-validation.patch
@@ -0,0 +1,56 @@
+# reject crafted caches whose FcCharSet offsets point outside the cache (arbitrary free)
+# https://gitlab.freedesktop.org/fontconfig/fontconfig/-/commit/4ba7952e (issue #558)
+diff --git a/src/fccache.c b/src/fccache.c
+index 8cce6f2d..cdb36eab 100644
+--- a/src/fccache.c
++++ b/src/fccache.c
+@@ -970,6 +970,49 @@ FcCacheOffsetsValid (FcCache *cache)
+ }
+ return FcFalse;
+ }
++ {
++ const FcCharSet *cs = FcValueCharSet (&l->value);
++ intptr_t *leaves;
++ int k;
++
++ if ((char *)cs < base || (char *)cs > end - sizeof (FcCharSet) ||
++ !FcRefIsConst (&cs->ref)) {
++ if (FcDebug() & FC_DBG_CACHE) {
++ fprintf (stderr, "Fontconfig warning: invalid cache: non-constant or out-of-bounds charset\n");
++ }
++ return FcFalse;
++ }
++ if (cs->num < 0)
++ return FcFalse;
++ if (cs->num > 0) {
++ if (cs->leaves_offset < 0 ||
++ cs->leaves_offset > end - (char *)cs ||
++ cs->num > (end - (char *)cs - cs->leaves_offset) / sizeof (intptr_t)) {
++ if (FcDebug() & FC_DBG_CACHE) {
++ fprintf (stderr, "Fontconfig warning: invalid cache: broken charset leaves offset\n");
++ }
++ return FcFalse;
++ }
++ if (cs->numbers_offset < 0 ||
++ cs->numbers_offset > end - (char *)cs ||
++ cs->num > (end - (char *)cs - cs->numbers_offset) / sizeof (FcChar16)) {
++ if (FcDebug() & FC_DBG_CACHE) {
++ fprintf (stderr, "Fontconfig warning: invalid cache: broken charset numbers offset\n");
++ }
++ return FcFalse;
++ }
++ leaves = FcCharSetLeaves (cs);
++ for (k = 0; k < cs->num; k++) {
++ if (leaves[k] < -((char *)leaves - base) ||
++ leaves[k] > end - (char *)leaves - (ptrdiff_t) sizeof (FcCharLeaf)) {
++ if (FcDebug() & FC_DBG_CACHE) {
++ fprintf (stderr, "Fontconfig warning: invalid cache: broken charset leaf offset\n");
++ }
++ return FcFalse;
++ }
++ }
++ }
++ }
+ break;
+ case FcTypeLangSet:
+ ls = FcValueLangSet (&l->value);
diff --git a/fontconfig-cache-type-validation.patch b/fontconfig-cache-type-validation.patch
new file mode 100644
index 0000000..5715adb
--- /dev/null
+++ b/fontconfig-cache-type-validation.patch
@@ -0,0 +1,28 @@
+# reject crafted caches storing a value type that does not match its object
+# https://gitlab.freedesktop.org/fontconfig/fontconfig/-/commit/3611892e
+diff --git a/src/fccache.c b/src/fccache.c
+index cdb36eab..e9ea3cc3 100644
+--- a/src/fccache.c
++++ b/src/fccache.c
+@@ -940,6 +940,21 @@ FcCacheOffsetsValid (FcCache *cache)
+ if ((char *)l < last_offset || (char *)l > end - sizeof (*l) ||
+ (l->next != NULL && !FcIsEncodedOffset (l->next)))
+ return FcFalse;
++ /* The checks below are driven by the type stored in the
++ * value, whereas the users of a pattern pick the accessor
++ * for a value by the object it belongs to. Reject values
++ * whose type doesn't match the type registered for the
++ * object, otherwise e.g. an integer stored for FC_FAMILY
++ * would be accepted here without validating the union,
++ * but dereferenced as a string later on.
++ */
++ if (!FcObjectValidType (e[j].object, l->value.type)) {
++ if (FcDebug() & FC_DBG_CACHE) {
++ fprintf (stderr, "Fontconfig warning: invalid cache: value of type %d doesn't match the type of object %d\n",
++ l->value.type, e[j].object);
++ }
++ return FcFalse;
++ }
+ switch (l->value.type) {
+ case FcTypeVoid:
+ case FcTypeInteger:
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/fontconfig.git/commitdiff/d29dbd99395fcb00e13d4adc48fcc4f7dc88a024
More information about the pld-cvs-commit
mailing list