all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: rennes@openmailbox.org
To: ludo@gnu.org
Cc: guix-devel@gnu.org
Subject: Re: [PATCH] gnu: Add fontconfig-path-max.
Date: Tue, 12 Jul 2016 09:08:14 -0500	[thread overview]
Message-ID: <328a872d39b4913fa06c623e24838363@openmailbox.org> (raw)
In-Reply-To: <87furozcvo.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1053 bytes --]

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.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-Add-fontconfig.patch --]
[-- Type: text/x-diff; name=0001-gnu-Add-fontconfig.patch, Size: 5113 bytes --]

From a2024a55c8ff0a755b9fca06b35b0d337ce2e577 Mon Sep 17 00:00:00 2001
From: Rene Saavedra <rennes@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 <mhw@netris.org>
 # Copyright © 2016 Chris Marusich <cmmarusich@gmail.com>
 # Copyright © 2016 Kei Yamashita <kei@openmailbox.org>
+# Copyright © 2016 Rene Saavedra <rennes@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 <bavier@member.fsf.org>
 ;;; Copyright © 2016 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2016 Rene Saavedra <rennes@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


  reply	other threads:[~2016-07-12 14:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-18 19:02 [PATCH] gnu: Add fontconfig-path-max rennes
2016-07-03 22:24 ` Manolis Ragkousis
2016-07-04  4:02   ` rennes
2016-07-04  7:55     ` Manolis Ragkousis
2016-07-05  1:46       ` rennes
2016-07-04  8:16 ` Ludovic Courtès
2016-07-04  8:21 ` Ludovic Courtès
2016-07-05  1:26   ` rennes
2016-07-05  8:51     ` Ludovic Courtès
2016-07-12 14:08       ` rennes [this message]
2016-07-12 14:25         ` rennes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=328a872d39b4913fa06c623e24838363@openmailbox.org \
    --to=rennes@openmailbox.org \
    --cc=guix-devel@gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.