~ruther/guix-local

b093be236efa913748855879094e38cd983c7f00 — Marius Bakke 8 years ago 171bcdf
gnu: gd: Remove graft for 2.2.5.

* gnu/packages/gd.scm (gd): Update to 2.2.5.
[source]: Remove obsolete patches.
[replacement]: Remove field.
(gd-2.2.5): Remove variable.
* gnu/packages/patches/gd-fix-gd2-read-test.patch,
gnu/packages/patches/gd-php-73968-Fix-109-XBM-reading.patch: Delete files.
* gnu/local.mk (dist_patch_DATA): Remove patches.
* gnu/packages/php.scm (php)[inputs]: Replace GD-2.2.5 with GD.
5 files changed, 5 insertions(+), 161 deletions(-)

M gnu/local.mk
M gnu/packages/gd.scm
D gnu/packages/patches/gd-fix-gd2-read-test.patch
D gnu/packages/patches/gd-php-73968-Fix-109-XBM-reading.patch
M gnu/packages/php.scm
M gnu/local.mk => gnu/local.mk +0 -2
@@ 638,10 638,8 @@ dist_patch_DATA =						\
  %D%/packages/patches/gcc-6-cross-environment-variables.patch	\
  %D%/packages/patches/gcr-disable-failing-tests.patch		\
  %D%/packages/patches/gcr-fix-collection-tests-to-work-with-gpg-21.patch	\
  %D%/packages/patches/gd-fix-gd2-read-test.patch		\
  %D%/packages/patches/gd-fix-tests-on-i686.patch		\
  %D%/packages/patches/gd-freetype-test-failure.patch		\
  %D%/packages/patches/gd-php-73968-Fix-109-XBM-reading.patch		\
  %D%/packages/patches/gegl-CVE-2012-4433.patch			\
  %D%/packages/patches/gemma-intel-compat.patch			\
  %D%/packages/patches/geoclue-config.patch			\

M gnu/packages/gd.scm => gnu/packages/gd.scm +4 -23
@@ 38,11 38,10 @@
(define-public gd
  (package
    (name "gd")
    (replacement gd-2.2.5)
    ;; Note: With libgd.org now pointing to github.com, genuine old
    ;; tarballs are no longer available.  Notably, versions 2.0.x are
    ;; missing.
    (version "2.2.4")
    (version "2.2.5")
    (source (origin
             (method url-fetch)
             (uri (string-append


@@ 50,11 49,9 @@
                   version "/libgd-" version ".tar.xz"))
             (sha256
              (base32
               "1rp4v7n1dq38b92kl7gkvpvqqkw7nvdfnz6d5kip5klkxfki6zqk"))
             (patches (search-patches "gd-fix-gd2-read-test.patch"
                                      "gd-fix-tests-on-i686.patch"
                                      "gd-freetype-test-failure.patch"
                                      "gd-php-73968-Fix-109-XBM-reading.patch"))))
               "0lfy5f241sbv8s3splm2zqiaxv7lxrcshh875xryryk7yk5jqc4c"))
             (patches (search-patches "gd-fix-tests-on-i686.patch"
                                      "gd-freetype-test-failure.patch"))))
    (build-system gnu-build-system)
    (arguments
      ;; As recommended by github.com/libgd/libgd/issues/278 to fix rounding


@@ 93,22 90,6 @@ most common applications of GD involve website development.")
                           "See COPYING file in the distribution."))
    (properties '((cpe-name . "libgd")))))

;; For CVE-2017-6362 and CVE-2017-7890.
(define-public gd-2.2.5
  (package
    (inherit gd)
    (version "2.2.5")
    (source (origin
              (method url-fetch)
              (uri (string-append
                    "https://github.com/libgd/libgd/releases/download/gd-"
                    version "/libgd-" version ".tar.xz"))
              (patches (search-patches "gd-fix-tests-on-i686.patch"
                                       "gd-freetype-test-failure.patch"))
              (sha256
               (base32
                "0lfy5f241sbv8s3splm2zqiaxv7lxrcshh875xryryk7yk5jqc4c"))))))

(define-public perl-gd
  (package
    (name "perl-gd")

D gnu/packages/patches/gd-fix-gd2-read-test.patch => gnu/packages/patches/gd-fix-gd2-read-test.patch +0 -14
@@ 1,14 0,0 @@
Fix a 'maybe-uninitialized' warning (turned error)
which occurs on non-Intel platforms.

--- libgd-2.2.3/tests/gd2/gd2_read.c	2016-07-21 01:21:16.000000000 -0400
+++ libgd-2.2.3/tests/gd2/gd2_read.c	2016-07-29 15:52:03.806405312 -0400
@@ -5,7 +5,7 @@
 
 int main(int argc, char *argv[])
 {
-	int error, i = 0;
+	int error = 0, i = 0;
 	gdImagePtr im, exp;
 	FILE *fp;
 	char *path[] = {

D gnu/packages/patches/gd-php-73968-Fix-109-XBM-reading.patch => gnu/packages/patches/gd-php-73968-Fix-109-XBM-reading.patch +0 -121
@@ 1,121 0,0 @@
This bug was first reported to php on https://bugs.php.net/bug.php?id=73968.
php then reported it to gd in https://github.com/libgd/libgd/issues/109.

Patch adapted from upstream source repository:

https://github.com/libgd/libgd/commit/082c5444838ea0d84f9fb6441aefdb44d78d9bba

Binary diffs have been removed from the patch because our patch
procedure doesn't support them.

From 082c5444838ea0d84f9fb6441aefdb44d78d9bba Mon Sep 17 00:00:00 2001
From: "Christoph M. Becker" <cmbecker69@gmx.de>
Date: Fri, 20 Jan 2017 22:48:20 +0100
Subject: [PATCH] Fix #109: XBM reading fails with printed error

When calculating the number of required bytes of an XBM image, we have
to take the line padding into account.
---
 src/gd_xbm.c                     |   2 +-
 tests/xbm/CMakeLists.txt         |   1 +
 tests/xbm/Makemodule.am          |   5 ++++-
 tests/xbm/github_bug_109.c       |  35 +++++++++++++++++++++++++++++++++++
 tests/xbm/github_bug_109.xbm     |   5 +++++
 5 files changed, 47 insertions(+), 2 deletions(-)
 create mode 100644 tests/xbm/github_bug_109.c
 create mode 100644 tests/xbm/github_bug_109.xbm
 create mode 100644 tests/xbm/github_bug_109_exp.png

diff --git a/src/gd_xbm.c b/src/gd_xbm.c
index 5f09b56..c2ba2ad 100644
--- a/src/gd_xbm.c
+++ b/src/gd_xbm.c
@@ -108,7 +108,7 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromXbm(FILE * fd)
 				max_bit = 32768;
 			}
 			if (max_bit) {
-				bytes = (width * height / 8) + 1;
+                bytes = (width + 7) / 8 * height;
 				if (!bytes) {
 					return 0;
 				}
diff --git a/tests/xbm/CMakeLists.txt b/tests/xbm/CMakeLists.txt
index 183cf5e..08576e0 100644
--- a/tests/xbm/CMakeLists.txt
+++ b/tests/xbm/CMakeLists.txt
@@ -1,4 +1,5 @@
 LIST(APPEND TESTS_FILES
+	github_bug_109
 	github_bug_170
 )
 
diff --git a/tests/xbm/Makemodule.am b/tests/xbm/Makemodule.am
index ba1eabd..0f5beb6 100644
--- a/tests/xbm/Makemodule.am
+++ b/tests/xbm/Makemodule.am
@@ -1,5 +1,8 @@
 libgd_test_programs += \
+	xbm/github_bug_109 \
 	xbm/github_bug_170
 
 EXTRA_DIST += \
-	xbm/CMakeLists.txt
+	xbm/CMakeLists.txt \
+	xbm/github_bug_109.xbm \
+	xbm/github_bug_109_exp.png
diff --git a/tests/xbm/github_bug_109.c b/tests/xbm/github_bug_109.c
new file mode 100644
index 0000000..1a020c6
--- /dev/null
+++ b/tests/xbm/github_bug_109.c
@@ -0,0 +1,35 @@
+/**
+ * Test reading of XBM images with a width that is not a multiple of 8
+ *
+ * We're reading such an XBM image, and check that we got what we've expected,
+ * instead of an error message.
+ *
+ * See also <https://github.com/libgd/libgd/issues/109>.
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+    gdImagePtr im;
+    FILE *fp;
+    char *path;
+
+    fp = gdTestFileOpen2("xbm", "github_bug_109.xbm");
+    im = gdImageCreateFromXbm(fp);
+    fclose(fp);
+    gdTestAssert(im != NULL);
+    gdTestAssert(gdImageGetTrueColorPixel(im, 0, 0) == 0);
+    gdTestAssert(gdImageGetTrueColorPixel(im, 0, 1) == 0xffffff);
+
+    path = gdTestFilePath2("xbm", "github_bug_109_exp.png");
+    gdAssertImageEqualsToFile(path, im);
+    gdFree(path);
+
+    gdImageDestroy(im);
+
+    return gdNumFailures();
+}
diff --git a/tests/xbm/github_bug_109.xbm b/tests/xbm/github_bug_109.xbm
new file mode 100644
index 0000000..f427d86
--- /dev/null
+++ b/tests/xbm/github_bug_109.xbm
@@ -0,0 +1,5 @@
+#define test_width 10
+#define test_height 10
+static unsigned char test_bits[] = {
+  0xFF, 0x03, 0x00, 0x00, 0xFF, 0x03, 0x00, 0x00, 0xFF, 0x03, 0x00, 0x00, 
+  0xFF, 0x03, 0x00, 0x00, 0xFF, 0x03, 0x00, 0x00};

-- 
2.7.4


M gnu/packages/php.scm => gnu/packages/php.scm +1 -1
@@ 282,7 282,7 @@
       ("curl" ,curl)
       ("cyrus-sasl" ,cyrus-sasl)
       ("freetype" ,freetype)
       ("gd" ,gd-2.2.5)
       ("gd" ,gd)
       ("gdbm" ,gdbm)
       ("glibc" ,glibc)
       ("gmp" ,gmp)