From 49482353acaae83f37b98c13a2e414e23c73436b Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Thu, 4 Dec 2014 13:22:54 +0000
Subject: gd: update to 2.1.0

---
 abs/extra/gd/PKGBUILD                   | 41 +++++++++++++++++++++------------
 abs/extra/gd/color_c_null_pointer.patch | 18 +++++++++++++++
 abs/extra/gd/libpng14.patch             | 12 ----------
 3 files changed, 44 insertions(+), 27 deletions(-)
 create mode 100644 abs/extra/gd/color_c_null_pointer.patch
 delete mode 100644 abs/extra/gd/libpng14.patch

diff --git a/abs/extra/gd/PKGBUILD b/abs/extra/gd/PKGBUILD
index 2d89e7b..b050624 100644
--- a/abs/extra/gd/PKGBUILD
+++ b/abs/extra/gd/PKGBUILD
@@ -1,31 +1,42 @@
-# $Id: PKGBUILD 148724 2012-02-05 11:48:15Z ibiru $
-# Maintainer: Eric Belanger <eric@archlinux.org>
+# $Id$
 
 pkgname=gd
-pkgver=2.0.36RC1
-pkgrel=5
+pkgver=2.1.0
+pkgrel=3
 pkgdesc="Library for the dynamic creation of images by programmers"
 arch=('i686' 'x86_64')
 url="http://www.libgd.org/"
 license=('custom')
-depends=('libpng' 'fontconfig' 'libjpeg')
+depends=('fontconfig' 'libvpx' 'libxpm' 'libtiff')
 optdepends=('perl: bdftogd script')
-options=('!libtool')
-source=("ftp://ftp.archlinux.org/other/${pkgname}/${pkgname}-${pkgver}.tar.bz2"
-        'libpng14.patch')
-md5sums=('e876979ca3130623a4e7866d9579171a'
-         '7921556f4960e8d66cf4fb67ea7101b5')
+source=("https://bitbucket.org/libgd/gd-libgd/downloads/libgd-${pkgver}.tar.xz"
+        'color_c_null_pointer.patch')
+md5sums=('03588159bf4faab9079849c8d709acc6'
+         '51f5ff073eabbd7809e0ce438d5bb1c2')
 
-build() {
-  cd "${srcdir}/${pkgname}-${pkgver}"
+prepare() {
+  cd libgd-${pkgver}
+  # CVE-2014-2497
+  patch -p1 -i ${srcdir}/color_c_null_pointer.patch
+}
 
-  patch -Np1 -i ${srcdir}/libpng14.patch
-  ./configure --prefix=/usr --without-xpm
+build() {
+  cd libgd-${pkgver}
+  ./configure \
+    --prefix=/usr \
+    --disable-rpath \
+    --with-vpx=/usr \
+    --with-tiff=/usr
   make
 }
 
+check() {
+  cd libgd-${pkgver}
+  make check
+}
+
 package() {
-  cd "${srcdir}/${pkgname}-${pkgver}"
+  cd libgd-${pkgver}
   make DESTDIR="${pkgdir}" install
   install -D -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
 }
diff --git a/abs/extra/gd/color_c_null_pointer.patch b/abs/extra/gd/color_c_null_pointer.patch
new file mode 100644
index 0000000..95b3eeb
--- /dev/null
+++ b/abs/extra/gd/color_c_null_pointer.patch
@@ -0,0 +1,18 @@
+diff -up ./src/gdxpm.c.color_c_null_pointer ./src/gdxpm.c
+--- ./src/gdxpm.c.color_c_null_pointer	2013-06-25 11:58:23.000000000 +0200
++++ ./src/gdxpm.c	2014-07-16 16:43:44.000000000 +0200
+@@ -62,6 +62,13 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFro
+ 
+ 	for(i = 0; i < number; i++) {
+ 		char *c_color = image.colorTable[i].c_color;
++		if (!c_color)
++		{
++			/* unsupported color key or color key not defined */
++			gdImageDestroy(im);
++			im = 0;
++			goto done;
++		}
+ 		if(strcmp(c_color, "None") == 0) {
+ 			colors[i] = gdImageGetTransparent(im);
+ 			if(colors[i] == -1) colors[i] = gdImageColorAllocate(im, 0, 0, 0);
+diff -up ./x.color_c_null_pointer ./x
diff --git a/abs/extra/gd/libpng14.patch b/abs/extra/gd/libpng14.patch
deleted file mode 100644
index 19a3fda..0000000
--- a/abs/extra/gd/libpng14.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -Nur gd-2.0.36RC1.orig/gd_png.c gd-2.0.36RC1/gd_png.c
---- gd-2.0.36RC1.orig/gd_png.c	2007-11-27 10:30:34.000000000 +0200
-+++ gd-2.0.36RC1/gd_png.c	2010-01-17 17:14:11.000000000 +0200
-@@ -151,7 +151,7 @@
- 	return NULL;
-   }
- 
--	if (!png_check_sig (sig, 8)) { /* bad signature */
-+	if (png_sig_cmp (sig, 0, 8)) { /* bad signature */
-     	return NULL;		/* bad signature */
- 	}
- 
-- 
cgit v0.12