all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] gnu: Add fontconfig-path-max.
@ 2016-06-18 19:02 rennes
  2016-07-03 22:24 ` Manolis Ragkousis
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: rennes @ 2016-06-18 19:02 UTC (permalink / raw)
  To: guix-devel

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

Hello Guix team,

i'm doing tests whith GNU Guix on GNU Hurd, compiling fontconfig and 
there is an error during compilation:

a) fontconfig uses the constant PATH_MAX.

Reviewing the documentation about the treatment of constant for Hurd; 
i've attached a patch for review.

References:
https://www.gnu.org/software/hurd/community/gsoc/project_ideas/maxpath.html
https://www.gnu.org/software/hurd/hurd/porting/guidelines.html

and i've a couple of questions about:

a) How Guix identify if it is a Linux or Hurd system at compile or 
install the package?.
b) i searches in ML an example, but i not found.



Thanks for your time.

Rene

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

From 3195bf1e75493675dc8cbd81a0f83e0b4538263b Mon Sep 17 00:00:00 2001
From: Rene Saavedra <rennes@openmailbox.org>
Date: Sat, 18 Jun 2016 13:37:19 -0500
Subject: [PATCH] gnu: Add fontconfig-path-max.

---
 gnu/packages/fontutils.scm                      |  3 +++
 gnu/packages/patches/fontconfig-fcdefault.patch | 23 +++++++++++++++++++++++
 gnu/packages/patches/fontconfig-fcstat.patch    | 23 +++++++++++++++++++++++
 3 files changed, 49 insertions(+)
 create mode 100644 gnu/packages/patches/fontconfig-fcdefault.patch
 create mode 100644 gnu/packages/patches/fontconfig-fcstat.patch

diff --git a/gnu/packages/fontutils.scm b/gnu/packages/fontutils.scm
index 5f6ff15..2b84523 100644
--- a/gnu/packages/fontutils.scm
+++ b/gnu/packages/fontutils.scm
@@ -231,6 +231,9 @@ fonts to/from the WOFF2 format.")
             (uri (string-append
                    "https://www.freedesktop.org/software/fontconfig/release/fontconfig-"
                    version ".tar.bz2"))
+            (patches (list
+                      (search-patch "fontconfig-fcdefault.patch")
+                      (search-patch "fontconfig-fcstat.patch")))
             (sha256 (base32
                      "1psrl4b4gi4wmbvwwh43lk491wsl8lgvqj146prlcha3vwjc0qyp"))))
    (build-system gnu-build-system)
diff --git a/gnu/packages/patches/fontconfig-fcdefault.patch b/gnu/packages/patches/fontconfig-fcdefault.patch
new file mode 100644
index 0000000..9c3b383
--- /dev/null
+++ b/gnu/packages/patches/fontconfig-fcdefault.patch
@@ -0,0 +1,23 @@
+This patch replaces the use of macro PATH_MAX by *buf constant,
+which allows dynamic memory allocation.
+
+---
+ src/fcdefault.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/fcdefault.c b/src/fcdefault.c
+index 6647a8f..8e2094f 100644
+--- a/src/fcdefault.c
++++ b/src/fcdefault.c
+@@ -150,7 +150,7 @@ retry:
+ # if defined (HAVE_GETEXECNAME)
+ 	const char *p = getexecname ();
+ # elif defined (HAVE_READLINK)
+-	char buf[PATH_MAX + 1];
++	char *buf;
+ 	int len;
+ 	char *p = NULL;
+ 
+-- 
+2.6.3
+
diff --git a/gnu/packages/patches/fontconfig-fcstat.patch b/gnu/packages/patches/fontconfig-fcstat.patch
new file mode 100644
index 0000000..e075b17
--- /dev/null
+++ b/gnu/packages/patches/fontconfig-fcstat.patch
@@ -0,0 +1,23 @@
+This patch replaces the use of macro PATH_MAX by *f constant,
+which allows dynamic memory allocation.
+
+---
+ src/fcstat.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/fcstat.c b/src/fcstat.c
+index 1734fa4..8a438eb 100644
+--- a/src/fcstat.c
++++ b/src/fcstat.c
+@@ -278,7 +278,7 @@ FcDirChecksum (const FcChar8 *dir, time_t *checksum)
+ 	{
+ #endif
+ 	struct stat statb;
+-	char f[PATH_MAX + 1];
++	char *f;
+ 
+ 	memcpy (f, dir, len);
+ 	f[len] = FC_DIR_SEPARATOR;
+-- 
+2.6.3
+
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] gnu: Add fontconfig-path-max.
  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  8:16 ` Ludovic Courtès
  2016-07-04  8:21 ` Ludovic Courtès
  2 siblings, 1 reply; 11+ messages in thread
From: Manolis Ragkousis @ 2016-07-03 22:24 UTC (permalink / raw)
  To: rennes; +Cc: guix-devel

Hello Rennes,

I am sorry for the long delay, I somehow missed the patch. Leo thank you
for telling me.

On 06/18/16 22:02, rennes@openmailbox.org wrote:
> Hello Guix team,
> 
> i'm doing tests whith GNU Guix on GNU Hurd, compiling fontconfig and
> there is an error during compilation:

Once again thank you :-)
> 
> a) fontconfig uses the constant PATH_MAX.
> 
> Reviewing the documentation about the treatment of constant for Hurd;
> i've attached a patch for review.
> 
> References:
> https://www.gnu.org/software/hurd/community/gsoc/project_ideas/maxpath.html
> https://www.gnu.org/software/hurd/hurd/porting/guidelines.html
> 
> and i've a couple of questions about:
> 
> a) How Guix identify if it is a Linux or Hurd system at compile or
> install the package?.
> b) i searches in ML an example, but i not found.

Currently we apply patches regardless of where it is running.

But one way to check the system is like in (gnu packages base)

(define* (glibc-for-target #:optional
                           (target (or (%current-target-system)
                                       (%current-system))))
  "Return the glibc for TARGET, GLIBC/LINUX for a Linux host or
GLIBC/HURD for a Hurd host"
  (match target
    ((or "i586-pc-gnu" "i586-gnu") glibc/hurd)
    (_ glibc/linux)))

If %current-target-system is not #f then we are cross-building for the
value inside it. %current-system has the value of the system we are
running on.

Now regarding the patch, what is the status on upstream? Are those
fontconfig patches present in fontconfig upstream?

Other than that, it looks good to me.

Thank you for helping on this,
Manolis.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] gnu: Add fontconfig-path-max.
  2016-07-03 22:24 ` Manolis Ragkousis
@ 2016-07-04  4:02   ` rennes
  2016-07-04  7:55     ` Manolis Ragkousis
  0 siblings, 1 reply; 11+ messages in thread
From: rennes @ 2016-07-04  4:02 UTC (permalink / raw)
  To: Manolis Ragkousis; +Cc: guix-devel

Hello,

thanks for the explanation.

> 
> Now regarding the patch, what is the status on upstream? Are those
> fontconfig patches present in fontconfig upstream?
> 

The current release is 2.12.0, and still uses the constant PATH_MAX.
And I have not found any related patch for this detail.

Thanks

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] gnu: Add fontconfig-path-max.
  2016-07-04  4:02   ` rennes
@ 2016-07-04  7:55     ` Manolis Ragkousis
  2016-07-05  1:46       ` rennes
  0 siblings, 1 reply; 11+ messages in thread
From: Manolis Ragkousis @ 2016-07-04  7:55 UTC (permalink / raw)
  To: rennes; +Cc: guix-devel

Hello,

On 07/04/16 07:02, rennes@openmailbox.org wrote:
> The current release is 2.12.0, and still uses the constant PATH_MAX.
> And I have not found any related patch for this detail.

Could you send the related patches to fontconfig upstream and see what
they think about them?

Thank you,
Manolis

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] gnu: Add fontconfig-path-max.
  2016-06-18 19:02 [PATCH] gnu: Add fontconfig-path-max rennes
  2016-07-03 22:24 ` Manolis Ragkousis
@ 2016-07-04  8:16 ` Ludovic Courtès
  2016-07-04  8:21 ` Ludovic Courtès
  2 siblings, 0 replies; 11+ messages in thread
From: Ludovic Courtès @ 2016-07-04  8:16 UTC (permalink / raw)
  To: rennes; +Cc: guix-devel

Hello!

And thank you Manolis to taking care of this.  :-)

rennes@openmailbox.org skribis:

> From 3195bf1e75493675dc8cbd81a0f83e0b4538263b Mon Sep 17 00:00:00 2001
> From: Rene Saavedra <rennes@openmailbox.org>
> Date: Sat, 18 Jun 2016 13:37:19 -0500
> Subject: [PATCH] gnu: Add fontconfig-path-max.
>
> ---
>  gnu/packages/fontutils.scm                      |  3 +++
>  gnu/packages/patches/fontconfig-fcdefault.patch | 23 +++++++++++++++++++++++
>  gnu/packages/patches/fontconfig-fcstat.patch    | 23 +++++++++++++++++++++++
>  3 files changed, 49 insertions(+)
>  create mode 100644 gnu/packages/patches/fontconfig-fcdefault.patch
>  create mode 100644 gnu/packages/patches/fontconfig-fcstat.patch
>
> diff --git a/gnu/packages/fontutils.scm b/gnu/packages/fontutils.scm
> index 5f6ff15..2b84523 100644
> --- a/gnu/packages/fontutils.scm
> +++ b/gnu/packages/fontutils.scm
> @@ -231,6 +231,9 @@ fonts to/from the WOFF2 format.")
>              (uri (string-append
>                     "https://www.freedesktop.org/software/fontconfig/release/fontconfig-"
>                     version ".tar.bz2"))
> +            (patches (list
> +                      (search-patch "fontconfig-fcdefault.patch")
> +                      (search-patch "fontconfig-fcstat.patch")))

Rather use (search-patches …).

I would join the two patches in a single ‘fontconfig-path-max.patch’.

The file needs to be added in gnu/local.mk.

Manolis: do you think you could apply it to ‘core-updates-next’ with
these changes?

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] gnu: Add fontconfig-path-max.
  2016-06-18 19:02 [PATCH] gnu: Add fontconfig-path-max rennes
  2016-07-03 22:24 ` Manolis Ragkousis
  2016-07-04  8:16 ` Ludovic Courtès
@ 2016-07-04  8:21 ` Ludovic Courtès
  2016-07-05  1:26   ` rennes
  2 siblings, 1 reply; 11+ messages in thread
From: Ludovic Courtès @ 2016-07-04  8:21 UTC (permalink / raw)
  To: rennes; +Cc: guix-devel

Oops, I spoke too fast.

rennes@openmailbox.org skribis:

> +++ b/gnu/packages/patches/fontconfig-fcdefault.patch
> @@ -0,0 +1,23 @@
> +This patch replaces the use of macro PATH_MAX by *buf constant,
> +which allows dynamic memory allocation.
> +
> +---
> + src/fcdefault.c | 2 +-
> + 1 file changed, 1 insertion(+), 1 deletion(-)
> +
> +diff --git a/src/fcdefault.c b/src/fcdefault.c
> +index 6647a8f..8e2094f 100644
> +--- a/src/fcdefault.c
> ++++ b/src/fcdefault.c
> +@@ -150,7 +150,7 @@ retry:
> + # if defined (HAVE_GETEXECNAME)
> + 	const char *p = getexecname ();
> + # elif defined (HAVE_READLINK)
> +-	char buf[PATH_MAX + 1];
> ++	char *buf;

[...]

> + 	struct stat statb;
> +-	char f[PATH_MAX + 1];
> ++	char *f;

With these changes, the code compiles but will crash at run time,
because ‘f’ and ‘buf’ are dangling pointers.

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

(In general, for PATH_MAX issues, Debian very likely already has a
patch.)

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] gnu: Add fontconfig-path-max.
  2016-07-04  8:21 ` Ludovic Courtès
@ 2016-07-05  1:26   ` rennes
  2016-07-05  8:51     ` Ludovic Courtès
  0 siblings, 1 reply; 11+ messages in thread
From: rennes @ 2016-07-05  1:26 UTC (permalink / raw)
  To: ludo; +Cc: guix-devel

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

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

[-- 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: 3247 bytes --]

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


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] gnu: Add fontconfig-path-max.
  2016-07-04  7:55     ` Manolis Ragkousis
@ 2016-07-05  1:46       ` rennes
  0 siblings, 0 replies; 11+ messages in thread
From: rennes @ 2016-07-05  1:46 UTC (permalink / raw)
  To: Manolis Ragkousis; +Cc: guix-devel


On 2016-07-04 02:55, Manolis Ragkousis wrote:
> Hello,
> 
> On 07/04/16 07:02, rennes@openmailbox.org wrote:
>> The current release is 2.12.0, and still uses the constant PATH_MAX.
>> And I have not found any related patch for this detail.
> 
> Could you send the related patches to fontconfig upstream and see what
> they think about them?
> 
> Thank you,
> Manolis

I will analyze and send the patches. For now I will use the Debian patch 
suggested by Ludo.

Thanks

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] gnu: Add fontconfig-path-max.
  2016-07-05  1:26   ` rennes
@ 2016-07-05  8:51     ` Ludovic Courtès
  2016-07-12 14:08       ` rennes
  0 siblings, 1 reply; 11+ messages in thread
From: Ludovic Courtès @ 2016-07-05  8:51 UTC (permalink / raw)
  To: rennes; +Cc: guix-devel

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] gnu: Add fontconfig-path-max.
  2016-07-05  8:51     ` Ludovic Courtès
@ 2016-07-12 14:08       ` rennes
  2016-07-12 14:25         ` rennes
  0 siblings, 1 reply; 11+ messages in thread
From: rennes @ 2016-07-12 14:08 UTC (permalink / raw)
  To: ludo; +Cc: guix-devel

[-- 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


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] gnu: Add fontconfig-path-max.
  2016-07-12 14:08       ` rennes
@ 2016-07-12 14:25         ` rennes
  0 siblings, 0 replies; 11+ messages in thread
From: rennes @ 2016-07-12 14:25 UTC (permalink / raw)
  To: ludo; +Cc: guix-devel

Additional,

I issue the command on GNU/Linux and GNU Hurd:

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

and compile correctly. How I do manual testing?



On 2016-07-12 09:08, rennes@openmailbox.org wrote:
> 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.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-07-12 14:26 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2016-07-12 14:25         ` rennes

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.