Hello,
Please see
<https://www.gnu.org/software/guix/manual/html_node/Submitting-Patches.html>
regarding commit logs. :-)
Reviewed and corrected in the patch.
+--- a/src/fcstat.c
++++ b/src/fcstat.c
+@@ -278,7 +278,8 @@ FcDirChecksum (const FcChar8 *dir, time_t
*checksum)
+ {
+ #endif
+ struct stat statb;
+- char f[PATH_MAX + 1];
++ int size = 128;
++ char *f = malloc (size);
This is not OK, in part because it introduces a memory leak. The fix
should be along the same lines as the rest of the patch.
As you suggested, I used the same logic to make this part of patch.
Could you check whether Debian has a patch for a more recent version of
Fontconfig?
The version (2.11.0-6.3) is the last version, and not contain a patch
for fcstat.c file. It is possible that the Debian team has not had
problems with this file to compile.
There is a Workaround that suggests mailing lists freedesktop.
https://lists.freedesktop.org/archives/dri-devel/2016-April/105704.html
Thanks for the comments.
From a2024a55c8ff0a755b9fca06b35b0d337ce2e577 Mon Sep 17 00:00:00 2001
From: Rene Saavedra <ren...@openmailbox.org>
Date: Tue, 12 Jul 2016 08:02:03 -0500
Subject: [PATCH] gnu: Add fontconfig.
* gnu/packages/fontutils.scm (fontconfig): Update to 2.12.0.
* gnu/packages/patches/fontconfig-path-max.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
---
gnu/local.mk | 2 +
gnu/packages/fontutils.scm | 9 ++-
gnu/packages/patches/fontconfig-path-max.patch | 100 +++++++++++++++++++++++++
3 files changed, 109 insertions(+), 2 deletions(-)
create mode 100644 gnu/packages/patches/fontconfig-path-max.patch
diff --git a/gnu/local.mk b/gnu/local.mk
index 2238506..bdd8e78 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -5,6 +5,7 @@
# Copyright © 2013, 2014, 2015, 2016 Mark H Weaver <m...@netris.org>
# Copyright © 2016 Chris Marusich <cmmarus...@gmail.com>
# Copyright © 2016 Kei Yamashita <k...@openmailbox.org>
+# Copyright © 2016 Rene Saavedra <ren...@openmailbox.org>
#
# This file is part of GNU Guix.
#
@@ -478,6 +479,7 @@ dist_patch_DATA = \
gnu/packages/patches/flint-ldconfig.patch \
gnu/packages/patches/fltk-shared-lib-defines.patch \
gnu/packages/patches/fltk-xfont-on-demand.patch \
+ gnu/packages/patches/fontconfig-path-max.patch \
gnu/packages/patches/fontforge-svg-modtime.patch \
gnu/packages/patches/freeimage-CVE-2015-0852.patch \
gnu/packages/patches/gawk-fts-test.patch \
diff --git a/gnu/packages/fontutils.scm b/gnu/packages/fontutils.scm
index 5f6ff15..c706e3e 100644
--- a/gnu/packages/fontutils.scm
+++ b/gnu/packages/fontutils.scm
@@ -3,6 +3,7 @@
;;; Copyright © 2014, 2016 Eric Bavier <bav...@member.fsf.org>
;;; Copyright © 2016 Mark H Weaver <m...@netris.org>
;;; Copyright © 2016 Efraim Flashner <efr...@flashner.co.il>
+;;; Copyright © 2016 Rene Saavedra <ren...@openmailbox.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -225,14 +226,18 @@ fonts to/from the WOFF2 format.")
(define-public fontconfig
(package
(name "fontconfig")
- (version "2.11.94")
+ (version "2.12.0")
(source (origin
(method url-fetch)
(uri (string-append
"https://www.freedesktop.org/software/fontconfig/release/fontconfig-"
version ".tar.bz2"))
(sha256 (base32
- "1psrl4b4gi4wmbvwwh43lk491wsl8lgvqj146prlcha3vwjc0qyp"))))
+ "0942gl0n9zh3lwha1bfvzq7mh7pzycfys8f2mbcgss0zzzpy8cxl"))
+ ;; The patch originates from the Debian project,
+ ;; see https://www.debian.org/
+ (patches (search-patches
+ "fontconfig-path-max.patch"))))
(build-system gnu-build-system)
(propagated-inputs `(("expat" ,expat)
("freetype" ,freetype)))
diff --git a/gnu/packages/patches/fontconfig-path-max.patch b/gnu/packages/patches/fontconfig-path-max.patch
new file mode 100644
index 0000000..1ceea12
--- /dev/null
+++ b/gnu/packages/patches/fontconfig-path-max.patch
@@ -0,0 +1,100 @@
+The patch replaces the use of macro PATH_MAX, in default.c and
+fcstat.c files.
+---
+ src/fcdefault.c | 32 +++++++++++++++++++++++++-------
+ src/fcstat.c | 28 +++++++++++++++++++++++-----
+ 2 files changed, 48 insertions(+), 12 deletions(-)
+
+diff --git a/src/fcdefault.c b/src/fcdefault.c
+index 6647a8f..4856777 100644
+--- a/src/fcdefault.c
++++ b/src/fcdefault.c
+@@ -150,15 +150,33 @@ retry:
+ # if defined (HAVE_GETEXECNAME)
+ const char *p = getexecname ();
+ # elif defined (HAVE_READLINK)
+- char buf[PATH_MAX + 1];
+- int len;
++ int size = 128;
+ char *p = NULL;
+
+- len = readlink ("/proc/self/exe", buf, sizeof (buf) - 1);
+- if (len != -1)
+- {
+- buf[len] = '\0';
+- p = buf;
++ while (1) {
++ char *buf = malloc (size);
++ int len;
++
++ if (buf == NULL)
++ break;
++
++ len = readlink ("/proc/self/exe", buf, size - 1);
++
++ if (len < 0)
++ {
++ free(buf);
++ break;
++ }
++
++ if (len < size - 1)
++ {
++ buf[len] = '\0';
++ p = buf;
++ break;
++ }
++
++ free (buf);
++ size *= 2;
+ }
+ # else
+ char *p = NULL;
+diff --git a/src/fcstat.c b/src/fcstat.c
+index 1734fa4..b2a5ddb 100644
+--- a/src/fcstat.c
++++ b/src/fcstat.c
+@@ -278,17 +278,35 @@ FcDirChecksum (const FcChar8 *dir, time_t *checksum)
+ {
+ #endif
+ struct stat statb;
+- char f[PATH_MAX + 1];
++ int size = 128;
++ char *f = malloc (size);
+
+- memcpy (f, dir, len);
+- f[len] = FC_DIR_SEPARATOR;
+- memcpy (&f[len + 1], files[n]->d_name, dlen);
+- f[len + 1 + dlen] = 0;
++ if (f == NULL)
++ break;
++
++ if (len < 0)
++ {
++ free(f);
++ break;
++ }
++
++ if (len < size - 1)
++ {
++ memcpy (f, dir, len);
++ f[len] = FC_DIR_SEPARATOR;
++ memcpy (&f[len + 1], files[n]->d_name, dlen);
++ f[len + 1 + dlen] = 0;
++ }
++
+ if (lstat (f, &statb) < 0)
+ {
+ ret = -1;
+ goto bail;
+ }
++
++ free (f);
++ size *= 2;
++
+ if (S_ISDIR (statb.st_mode))
+ goto bail;
+
+--
+2.6.3
+
--
2.6.3