From bf10ddd51b76640cce8e3fee6d1cc7fdc9e2b33a Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 23 Mar 2015 18:33:56 +0100 Subject: gd: fix version in gdlib.pc --- gd-2.0.33-BoxBound.patch | 22 --------------- gd-2.0.35-AALineThick.patch | 66 --------------------------------------------- gd-CVE-2014-2497.patch | 33 ----------------------- gd-loop.patch | 24 ----------------- gd-sa1.patch | 59 ---------------------------------------- gd.spec | 29 +++++++++++++------- getver.pl | 42 +++++++++++++++++++++++++++++ 7 files changed, 61 insertions(+), 214 deletions(-) delete mode 100644 gd-2.0.33-BoxBound.patch delete mode 100644 gd-2.0.35-AALineThick.patch delete mode 100644 gd-CVE-2014-2497.patch delete mode 100644 gd-loop.patch delete mode 100644 gd-sa1.patch create mode 100755 getver.pl diff --git a/gd-2.0.33-BoxBound.patch b/gd-2.0.33-BoxBound.patch deleted file mode 100644 index c5daf36..0000000 --- a/gd-2.0.33-BoxBound.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- gd-2.0.33/gdft.c.pom 2004-11-02 22:00:48.000000000 +0100 -+++ gd-2.0.33/gdft.c 2006-11-21 09:25:49.000000000 +0100 -@@ -1237,7 +1237,8 @@ - glyph_min.x = penf.x + slot->metrics.horiBearingX; - glyph_min.y = penf.y - slot->metrics.horiBearingY; - --#if 0 -+// #if 0 - this version of glyph_max.x setting fixes problem with -+// too large bouonding box - if (ch == ' ') /* special case for trailing space */ - { - glyph_max.x = penf.x + horiAdvance; -@@ -1246,7 +1247,8 @@ - { - glyph_max.x = glyph_min.x + slot->metrics.width; - } --#else -+//#else -+#if 0 - glyph_max.x = penf.x + horiAdvance; - #endif - glyph_max.y = glyph_min.y + slot->metrics.height; diff --git a/gd-2.0.35-AALineThick.patch b/gd-2.0.35-AALineThick.patch deleted file mode 100644 index 4349ada..0000000 --- a/gd-2.0.35-AALineThick.patch +++ /dev/null @@ -1,66 +0,0 @@ -diff -up gd-2.0.35/gd.c.AALineThick gd-2.0.35/gd.c ---- gd-2.0.35/gd.c.AALineThick 2007-06-19 22:25:51.000000000 +0200 -+++ gd-2.0.35/gd.c 2012-02-28 11:02:09.708015922 +0100 -@@ -3474,6 +3474,8 @@ static void gdImageAALine (gdImagePtr im - /* keep them as 32bits */ - long x, y, inc; - long dx, dy,tmp; -+ int w, wid, wstart; -+ int thick = im->thick; - - if (!im->trueColor) { - /* TBB: don't crash when the image is of the wrong type */ -@@ -3502,6 +3504,25 @@ static void gdImageAALine (gdImagePtr im - gdImageSetAAPixelColor(im, x1, y1, col, 0xFF); - return; - } -+ else { -+ double ag; -+ if (abs(dy) < abs(dx)) -+ ag = cos (atan2 (dy, dx)); -+ else -+ ag = sin (atan2 (dy, dx)); -+ if (ag != 0) -+ { -+ wid = abs(thick / ag); -+ } -+ else -+ { -+ wid = 1; -+ } -+ if (wid == 0) -+ { -+ wid = 1; -+ } -+ } - if (abs(dx) > abs(dy)) { - if (dx < 0) { - tmp = x1; -@@ -3518,8 +3539,11 @@ static void gdImageAALine (gdImagePtr im - inc = (dy * 65536) / dx; - /* TBB: set the last pixel for consistency (<=) */ - while ((x >> 16) <= x2) { -- gdImageSetAAPixelColor(im, x >> 16, y >> 16, col, (y >> 8) & 0xFF); -- gdImageSetAAPixelColor(im, x >> 16, (y >> 16) + 1,col, (~y >> 8) & 0xFF); -+ wstart = (y >> 16) - wid / 2; -+ for (w = wstart; w < wstart + wid; w++) { -+ gdImageSetAAPixelColor(im, (x >> 16) , w , col , (y >> 8) & 0xFF); -+ gdImageSetAAPixelColor(im, (x >> 16) , w + 1 , col, (~y >> 8) & 0xFF); -+ } - x += (1 << 16); - y += inc; - } -@@ -3539,8 +3563,11 @@ static void gdImageAALine (gdImagePtr im - inc = (dx * 65536) / dy; - /* TBB: set the last pixel for consistency (<=) */ - while ((y>>16) <= y2) { -- gdImageSetAAPixelColor(im, x >> 16, y >> 16, col, (x >> 8) & 0xFF); -- gdImageSetAAPixelColor(im, (x >> 16) + 1, (y >> 16),col, (~x >> 8) & 0xFF); -+ wstart = (x >> 16) - wid / 2; -+ for (w = wstart; w < wstart + wid; w++) { -+ gdImageSetAAPixelColor(im, w , y >> 16 , col, (x >> 8) & 0xFF); -+ gdImageSetAAPixelColor(im, w + 1, y >> 16, col, (~x >> 8) & 0xFF); -+ } - x += inc; - y += (1<<16); - } diff --git a/gd-CVE-2014-2497.patch b/gd-CVE-2014-2497.patch deleted file mode 100644 index 6a94c48..0000000 --- a/gd-CVE-2014-2497.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 463c3bd09bfe8e924e19acad7a2a6af16953a704 Mon Sep 17 00:00:00 2001 -From: Remi Collet -Date: Mon, 4 Aug 2014 10:31:25 +0200 -Subject: [PATCH] CVE-2014-2497, NULL pointer dereference, fix #126 - ---- - src/gdxpm.c | 10 ++++++++++ - 1 file changed, 10 insertions(+) - -diff --git a/src/gdxpm.c b/src/gdxpm.c -index ae6e336..15603a6 100644 ---- a/src/gdxpm.c -+++ b/src/gdxpm.c -@@ -49,6 +49,16 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromXpm(char *filename) - if(overflow2(sizeof(int), number)) { - goto done; - } -+ for(i = 0; i < number; i++) { -+ /* -+ avoid NULL pointer dereference -+ TODO better fix need to manage monochrome/monovisual -+ see m_color or g4_color or g_color -+ */ -+ if (!image.colorTable[i].c_color) { -+ goto done; -+ } -+ } - - colors = (int *)gdMalloc(sizeof(int) * number); - if(colors == NULL) { --- -1.8.5.2 - diff --git a/gd-loop.patch b/gd-loop.patch deleted file mode 100644 index 9d08965..0000000 --- a/gd-loop.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff -up gd-2.0.35/gd_gif_in.c.loop gd-2.0.35/gd_gif_in.c ---- gd-2.0.35/gd_gif_in.c.loop 2007-06-14 15:51:41.000000000 -0400 -+++ gd-2.0.35/gd_gif_in.c 2008-07-21 11:20:25.000000000 -0400 -@@ -453,16 +453,17 @@ LWZReadByte_(gdIOCtx *fd, LZW_STATIC_DAT - return sd->firstcode; - } else if (code == sd->end_code) { - int count; -+ int max_count = 1024; - unsigned char buf[260]; - - if (*ZeroDataBlockP) - return -2; - -- while ((count = GetDataBlock(fd, buf, ZeroDataBlockP)) > 0) -+ while ((count = GetDataBlock(fd, buf, ZeroDataBlockP)) > 0 && --max_count >= 0 ) - ; - -- if (count != 0) -- return -2; -+ if (count != 0 || max_count < 0 ) -+ return -2; - } - - incode = code; diff --git a/gd-sa1.patch b/gd-sa1.patch deleted file mode 100644 index dc2b1b9..0000000 --- a/gd-sa1.patch +++ /dev/null @@ -1,59 +0,0 @@ -These issues were found by Coverity static analysis tool - -Error: DEADCODE (CWE-561): [#def3] -gd-2.0.35/gd.c:3494: cond_cannot_single: Condition "dx == 0L", taking false branch. Now the value of "dx" cannot be equal to 0. -gd-2.0.35/gd.c:3502: cannot_single: At condition "dx == 0L", the value of "dx" cannot be equal to 0. -gd-2.0.35/gd.c:3502: dead_error_condition: The condition "dx == 0L" cannot be true. -gd-2.0.35/gd.c:3502: dead_error_line: Execution cannot reach this expression "dy == 0L" inside statement "if (dx == 0L && dy == 0L){ -...". - -Error: DEADCODE (CWE-561): [#def4] -gd-2.0.35/gd.c:1085: cond_cannot_single: Condition "dx == 0", taking false branch. Now the value of "dx" cannot be equal to 0. -gd-2.0.35/gd.c:1097: cannot_single: At condition "dx == 0", the value of "dx" cannot be equal to 0. -gd-2.0.35/gd.c:1097: dead_error_condition: The condition "dx == 0" cannot be true. -gd-2.0.35/gd.c:1097: dead_error_line: Execution cannot reach this expression "dy == 0" inside statement "if (dx == 0 && dy == 0){ - ...". - - -diff -up gd-2.0.35/gd.c.sa1 gd-2.0.35/gd.c ---- gd-2.0.35/gd.c.sa1 2012-12-05 16:23:09.289667430 +0100 -+++ gd-2.0.35/gd.c 2012-12-05 16:30:41.634854587 +0100 -@@ -1094,11 +1094,6 @@ BGD_DECLARE(void) gdImageLine (gdImagePt - { - /* More-or-less horizontal. use wid for vertical stroke */ - /* Doug Claar: watch out for NaN in atan2 (2.0.5) */ -- if ((dx == 0) && (dy == 0)) -- { -- wid = 1; -- } -- else - { - /* 2.0.12: Michael Schwartz: divide rather than multiply; - TBB: but watch out for /0! */ -@@ -3490,6 +3485,12 @@ static void gdImageAALine (gdImagePtr im - dx = x2 - x1; - dy = y2 - y1; - -+ if (dx == 0 && dy == 0) { -+ /* TBB: allow setting points */ -+ gdImageSetAAPixelColor(im, x1, y1, col, 0xFF); -+ return; -+ } -+ - /* Axis aligned lines */ - if (dx == 0) { - gdImageVLine(im, x1, y1, y2, col); -@@ -3499,12 +3500,7 @@ static void gdImageAALine (gdImagePtr im - return; - } - -- if (dx == 0 && dy == 0) { -- /* TBB: allow setting points */ -- gdImageSetAAPixelColor(im, x1, y1, col, 0xFF); -- return; -- } -- else { -+ { - double ag; - if (abs(dy) < abs(dx)) - ag = cos (atan2 (dy, dx)); diff --git a/gd.spec b/gd.spec index c43cb16..7384008 100644 --- a/gd.spec +++ b/gd.spec @@ -17,7 +17,7 @@ Name: gd Name: gd-last %endif Version: 2.1.1 -Release: 1%{?prever}%{?short}%{?dist} +Release: 2%{?prever}%{?short}%{?dist} Group: System Environment/Libraries License: MIT URL: http://libgd.bitbucket.org/ @@ -30,9 +30,10 @@ Source1: https://bitbucket.org/libgd/gd-libgd/downloads/libgd-%{version}-r %else Source0: https://bitbucket.org/libgd/gd-libgd/downloads/libgd-%{version}%{?prever:-%{prever}}.tar.xz %endif +# Missing in official archive, need for autoreconf +Source2: getver.pl Patch1: gd-2.1.0-multilib.patch -Patch2: gd-CVE-2014-2497.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildRequires: freetype-devel @@ -49,6 +50,7 @@ BuildRequires: libXpm-devel BuildRequires: zlib-devel BuildRequires: pkgconfig BuildRequires: libtool +BuildRequires: perl %description @@ -100,20 +102,19 @@ Provides: gd-devel = %{version}-%{release} The gd-devel package contains the development libraries and header files for gd, a graphics library for creating PNG and JPEG graphics. + %prep %setup -q -n libgd-%{version}%{?prever:-%{prever}} %patch1 -p1 -b .mlib -#patch2 -p1 -b .cve-20142-497 - -# https://bitbucket.org/libgd/gd-libgd/issue/77 -sed -e '/GD_VERSION_STRING/s/-alpha//' \ - -e '/GD_EXTRA_VERSION/s/alpha//' \ - -i src/gd.h -grep VERSION src/gd.h # Workaround for https://bugzilla.redhat.com/978415 touch src/vpx_config.h +# Workaround for missing file +cp %{SOURCE2} config/getver.pl + +: $(perl config/getver.pl) + # RHEL-5 auto* are too old %if 0%{?rhel} == 5 %if 0%{?commit:1} @@ -123,7 +124,8 @@ tar --extract --file - --keep-newer-files --strip-components 1 %else : regenerate autotool stuff if [ -f configure ]; then - autoreconf -fi + libtoolize --copy --force + autoreconf -vif else ./bootstrap.sh fi @@ -159,8 +161,12 @@ rm -f $RPM_BUILD_ROOT/%{_libdir}/libgd.a export XFAIL_TESTS="gdimagestringft/gdimagestringft_bbox" %endif +: Upstream test suite make check +: Check content of pkgconfig +grep %{version} $RPM_BUILD_ROOT%{_libdir}/pkgconfig/gdlib.pc + %post -p /sbin/ldconfig @@ -188,6 +194,9 @@ make check %changelog +* Mon Mar 23 2015 Remi Collet - 2.1.1-2 +- fix version in gdlib.pc + * Wed Jan 14 2015 Remi Collet - 2.1.1-1 - update to 2.1.1 final diff --git a/getver.pl b/getver.pl new file mode 100755 index 0000000..3838952 --- /dev/null +++ b/getver.pl @@ -0,0 +1,42 @@ +#!/usr/bin/env perl + +# Simple script to extract the version number parts from src/gd.h. If +# called with the middle word of the version macro, it prints the +# value of that macro. If called with no argument, it outputs a +# human-readable version string. This must be run in the project +# root. It is used by configure.ac and docs/naturaldocs/run_docs.sh. + +use strict; + +my $key = shift; +my @version_parts = (); + +open FH, ") { + next unless m{version605b5d1778}; + next unless /^#define\s+GD_([A-Z0-9]+)_VERSION+\s+(\S+)/; + my ($lk, $lv) = ($1, $2); + if ($lk eq $key) { + chomp $lv; + $lv =~ s/"//g; + + print $lv; # no newline + exit(0); # success! + } + + push @version_parts, $lv if (!$key); +} + +close(FH); + +if (scalar @version_parts == 4) { + my $result = join(".", @version_parts[0..2]); + $result .= $version_parts[3]; + $result =~ s/"//g; + print $result; + exit(0); +} + +exit(1); # failure -- cgit