diff mbox

gnu: Add fontconfig-path-max.

Message ID 811ca2f8679999e2777cb5e559e69c37@openmailbox.org
State New
Headers show

Commit Message

rennes@openmailbox.org July 5, 2016, 1:26 a.m. UTC
Hello,

> 
> We should instead use ‘01_path_max.patch’ from
> <http://http.debian.net/debian/pool/main/f/fontconfig/fontconfig_2.11.0-6.3.debian.tar.xz>.
> 

I attached the updated patch.

The code has changed in the current version, I used the version 2.12.0 
of the package to update the patch.

how i know if the program will crash at run time?.


Thanks for your guide

Comments

Ludovic Courtès July 5, 2016, 8:51 a.m. UTC | #1
Hi,

rennes@openmailbox.org skribis:

> The code has changed in the current version, I used the version 2.12.0
> of the package to update the patch.
>
> how i know if the program will crash at run time?.

You could build it on GNU/Linux, using:

  ./pre-inst-env guix build fontconfig -K

Hopefully Fontconfig’s test suite would trigger the crash, but manual
testing might be needed too.

> From 21f812c2f496bdb7c39e297f66e09ea35968ddfb Mon Sep 17 00:00:00 2001
> From: Rene Saavedra <rennes@openmailbox.org>
> Date: Mon, 4 Jul 2016 19:34:48 -0500
> Subject: [PATCH] gnu: Add fontconfig.

Please see
<https://www.gnu.org/software/guix/manual/html_node/Submitting-Patches.html>
regarding commit logs.  :-)


[...]

> +--- 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.

Could you check whether Debian has a patch for a more recent version of
Fontconfig?

Thanks,
Ludo’.
diff mbox

Patch

From 21f812c2f496bdb7c39e297f66e09ea35968ddfb Mon Sep 17 00:00:00 2001
From: Rene Saavedra <rennes@openmailbox.org>
Date: Mon, 4 Jul 2016 19:34:48 -0500
Subject: [PATCH] gnu: Add fontconfig.

---
 gnu/packages/fontutils.scm                     |  8 ++-
 gnu/packages/patches/fontconfig-path-max.patch | 69 ++++++++++++++++++++++++++
 2 files changed, 75 insertions(+), 2 deletions(-)
 create mode 100644 gnu/packages/patches/fontconfig-path-max.patch

diff --git a/gnu/packages/fontutils.scm b/gnu/packages/fontutils.scm
index 5f6ff15..8ae725b 100644
--- a/gnu/packages/fontutils.scm
+++ b/gnu/packages/fontutils.scm
@@ -225,14 +225,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 is based on the Debian patch.
+   ;; http://http.debian.net/debian/pool/main/f/fontconfig/fontconfig_2.11.0-6.3.debian.tar.xz
+            (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..6f5a9b7
--- /dev/null
+++ b/gnu/packages/patches/fontconfig-path-max.patch
@@ -0,0 +1,69 @@ 
+The patch replaces the use of macro PATH_MAX, in default.c and
+fcstat.c files.
+---
+ src/fcdefault.c | 32 +++++++++++++++++++++++++-------
+ src/fcstat.c    |  3 ++-
+ 2 files changed, 27 insertions(+), 8 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..0f1cc00 100644
+--- 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);
+ 
+ 	memcpy (f, dir, len);
+ 	f[len] = FC_DIR_SEPARATOR;
+-- 
+2.6.3
+
-- 
2.6.3