debian/0000755000000000000000000000000013435567423007202 5ustar debian/doc_cleaner.pl0000644000000000000000000000246312222240036011757 0ustar #!/usr/bin/perl # These corrections makes index.html from the libgd 2.0.11 source # pass the weblint check. my @lines=<>; my $text = join "", @lines; # must contain all or none of the parameters $text =~ s|<(body)[^>]*>|<$1>|i; # is of higher order than $text =~ s|(]*)?>)|$2$1|gis; $text =~ s|()([^<]*)|$2$1|gi; # requires closing $text =~ s|(][^<]*<(a)\s[^<]*)()|$1$3|gis; $text =~ s|(
<(a)\sname=[^<]+?()?([^<]*$4$7|gis; # cannot be nested $text =~ s|([^<]*\)[^<]*)()|$1$3$2|gis; # HREF parameter of must be quoted $text =~ s|href=([^"][^\s">]*)|href="$1"|gi; # <> not defining a tag must be escaped $text =~ s|<([^\s"@<>]+\@[^\s"@<>]+)>|<$1>|g; $text =~ s|(\s)<(\s)|$1<$2|g; $text =~ s|([^-]-)>|$1>|g; $text =~ s||<xxx>|; # Correct typos... $text =~ s|(void gdImageJpegCtx[^<]*)|$1|; $text =~ s|\n(
)|$1|; $text =~ s|
\n(
)|$1gdImageAlpha$2|; $text =~ s|(int gdImageBlue[^<]*)|
$1|; $text =~ s|VALIGN="TOP >|VALIGN="TOP">|g; $text =~ s|(

\n

)|\n$1|gis; print $text; debian/libgd3.symbols0000644000000000000000000002040312222240036011734 0ustar libgd.so.3 libgd3 #MINVER# * Build-Depends-Package: libgd-dev GD_COLOR_MAP_X11@Base 2.1.0~alpha~ gdAffineApplyToPointF@Base 2.1.0~alpha~ gdAffineConcat@Base 2.1.0~alpha~ gdAffineEqual@Base 2.1.0~alpha~ gdAffineExpansion@Base 2.1.0~alpha~ gdAffineFlip@Base 2.1.0~alpha~ gdAffineIdentity@Base 2.1.0~alpha~ gdAffineInvert@Base 2.1.0~alpha~ gdAffineRectilinear@Base 2.1.0~alpha~ gdAffineRotate@Base 2.1.0~alpha~ gdAffineScale@Base 2.1.0~alpha~ gdAffineShearHorizontal@Base 2.1.0~alpha~ gdAffineShearVertical@Base 2.1.0~alpha~ gdAffineTranslate@Base 2.1.0~alpha~ gdAlphaBlend@Base 2.1.0~alpha~ gdClearErrorMethod@Base 2.1.0~alpha~ gdColorMapLookup@Base 2.1.0~alpha~ gdDPExtractData@Base 2.1.0~alpha~ gdFTUseFontConfig@Base 2.1.0~alpha~ gdFontCacheSetup@Base 2.1.0~alpha~ gdFontCacheShutdown@Base 2.1.0~alpha~ gdFontGetGiant@Base 2.1.0~alpha~ gdFontGetLarge@Base 2.1.0~alpha~ gdFontGetMediumBold@Base 2.1.0~alpha~ gdFontGetSmall@Base 2.1.0~alpha~ gdFontGetTiny@Base 2.1.0~alpha~ gdFontGiant@Base 2.1.0~alpha~ gdFontLarge@Base 2.1.0~alpha~ gdFontMediumBold@Base 2.1.0~alpha~ gdFontSmall@Base 2.1.0~alpha~ gdFontTiny@Base 2.1.0~alpha~ gdFree@Base 2.1.0~alpha~ gdFreeFontCache@Base 2.1.0~alpha~ gdImageAABlend@Base 2.1.0~alpha~ gdImageAlphaBlending@Base 2.1.0~alpha~ gdImageArc@Base 2.1.0~alpha~ gdImageBmp@Base 2.1.0~alpha~ gdImageBmpCtx@Base 2.1.0~alpha~ gdImageBmpPtr@Base 2.1.0~alpha~ gdImageBoundsSafe@Base 2.1.0~alpha~ gdImageBrightness@Base 2.1.0~alpha~ gdImageChar@Base 2.1.0~alpha~ gdImageCharUp@Base 2.1.0~alpha~ gdImageClone@Base 2.1.0~rc2~ gdImageColor@Base 2.1.0~alpha~ gdImageColorAllocate@Base 2.1.0~alpha~ gdImageColorAllocateAlpha@Base 2.1.0~alpha~ gdImageColorClosest@Base 2.1.0~alpha~ gdImageColorClosestAlpha@Base 2.1.0~alpha~ gdImageColorClosestHWB@Base 2.1.0~alpha~ gdImageColorDeallocate@Base 2.1.0~alpha~ gdImageColorExact@Base 2.1.0~alpha~ gdImageColorExactAlpha@Base 2.1.0~alpha~ gdImageColorMatch@Base 2.1.0~alpha~ gdImageColorReplace@Base 2.1.0~alpha~ gdImageColorReplaceArray@Base 2.1.0~alpha~ gdImageColorReplaceCallback@Base 2.1.0~alpha~ gdImageColorReplaceThreshold@Base 2.1.0~alpha~ gdImageColorResolve@Base 2.1.0~alpha~ gdImageColorResolveAlpha@Base 2.1.0~alpha~ gdImageColorTransparent@Base 2.1.0~alpha~ gdImageCompare@Base 2.1.0~alpha~ gdImageContrast@Base 2.1.0~alpha~ gdImageConvolution@Base 2.1.0~alpha~ gdImageCopy@Base 2.1.0~alpha~ gdImageCopyMerge@Base 2.1.0~alpha~ gdImageCopyMergeGray@Base 2.1.0~alpha~ gdImageCopyResampled@Base 2.1.0~alpha~ gdImageCopyResized@Base 2.1.0~alpha~ gdImageCopyRotated@Base 2.1.0~alpha~ gdImageCreate@Base 2.1.0~alpha~ gdImageCreateFromBmp@Base 2.1.0~alpha~ gdImageCreateFromBmpCtx@Base 2.1.0~alpha~ gdImageCreateFromBmpPtr@Base 2.1.0~alpha~ gdImageCreateFromGd2@Base 2.1.0~alpha~ gdImageCreateFromGd2Ctx@Base 2.1.0~alpha~ gdImageCreateFromGd2Part@Base 2.1.0~alpha~ gdImageCreateFromGd2PartCtx@Base 2.1.0~alpha~ gdImageCreateFromGd2PartPtr@Base 2.1.0~alpha~ gdImageCreateFromGd2Ptr@Base 2.1.0~alpha~ gdImageCreateFromGd@Base 2.1.0~alpha~ gdImageCreateFromGdCtx@Base 2.1.0~alpha~ gdImageCreateFromGdPtr@Base 2.1.0~alpha~ gdImageCreateFromGif@Base 2.1.0~alpha~ gdImageCreateFromGifCtx@Base 2.1.0~alpha~ gdImageCreateFromGifPtr@Base 2.1.0~alpha~ gdImageCreateFromJpeg@Base 2.1.0~alpha~ gdImageCreateFromJpegCtx@Base 2.1.0~alpha~ gdImageCreateFromJpegCtxEx@Base 2.1.0~alpha~ gdImageCreateFromJpegEx@Base 2.1.0~alpha~ gdImageCreateFromJpegPtr@Base 2.1.0~alpha~ gdImageCreateFromJpegPtrEx@Base 2.1.0~alpha~ gdImageCreateFromPng@Base 2.1.0~alpha~ gdImageCreateFromPngCtx@Base 2.1.0~alpha~ gdImageCreateFromPngPtr@Base 2.1.0~alpha~ gdImageCreateFromPngSource@Base 2.1.0~alpha~ gdImageCreateFromTga@Base 2.1.0~alpha~ gdImageCreateFromTgaCtx@Base 2.1.0~alpha~ gdImageCreateFromTgaPtr@Base 2.1.0~alpha~ gdImageCreateFromTiff@Base 2.1.0~alpha~ gdImageCreateFromTiffCtx@Base 2.1.0~alpha~ gdImageCreateFromTiffPtr@Base 2.1.0~alpha~ gdImageCreateFromWBMP@Base 2.1.0~alpha~ gdImageCreateFromWBMPCtx@Base 2.1.0~alpha~ gdImageCreateFromWBMPPtr@Base 2.1.0~alpha~ gdImageCreateFromWebp@Base 2.1.0~alpha~ gdImageCreateFromWebpCtx@Base 2.1.0~alpha~ gdImageCreateFromWebpPtr@Base 2.1.0~alpha~ gdImageCreateFromXbm@Base 2.1.0~alpha~ gdImageCreateFromXpm@Base 2.1.0~alpha~ gdImageCreatePaletteFromTrueColor@Base 2.1.0~alpha~ gdImageCreateTrueColor@Base 2.1.0~alpha~ gdImageCrop@Base 2.1.0~alpha~ gdImageCropAuto@Base 2.1.0~alpha~ gdImageCropThreshold@Base 2.1.0~alpha~ gdImageDashedLine@Base 2.1.0~alpha~ gdImageDestroy@Base 2.1.0~alpha~ gdImageEdgeDetectQuick@Base 2.1.0~alpha~ gdImageEllipse@Base 2.1.0~alpha~ gdImageEmboss@Base 2.1.0~alpha~ gdImageFill@Base 2.1.0~alpha~ gdImageFillToBorder@Base 2.1.0~alpha~ gdImageFilledArc@Base 2.1.0~alpha~ gdImageFilledEllipse@Base 2.1.0~alpha~ gdImageFilledPolygon@Base 2.1.0~alpha~ gdImageFilledRectangle@Base 2.1.0~alpha~ gdImageFlipBoth@Base 2.1.0~alpha~ gdImageFlipHorizontal@Base 2.1.0~alpha~ gdImageFlipVertical@Base 2.1.0~alpha~ gdImageGaussianBlur@Base 2.1.0~alpha~ gdImageGd2@Base 2.1.0~alpha~ gdImageGd2Ptr@Base 2.1.0~alpha~ gdImageGd@Base 2.1.0~alpha~ gdImageGdPtr@Base 2.1.0~alpha~ gdImageGetClip@Base 2.1.0~alpha~ gdImageGetPixel@Base 2.1.0~alpha~ gdImageGetTrueColorPixel@Base 2.1.0~alpha~ gdImageGif@Base 2.1.0~alpha~ gdImageGifAnimAdd@Base 2.1.0~alpha~ gdImageGifAnimAddCtx@Base 2.1.0~alpha~ gdImageGifAnimAddPtr@Base 2.1.0~alpha~ gdImageGifAnimBegin@Base 2.1.0~alpha~ gdImageGifAnimBeginCtx@Base 2.1.0~alpha~ gdImageGifAnimBeginPtr@Base 2.1.0~alpha~ gdImageGifAnimEnd@Base 2.1.0~alpha~ gdImageGifAnimEndCtx@Base 2.1.0~alpha~ gdImageGifAnimEndPtr@Base 2.1.0~alpha~ gdImageGifCtx@Base 2.1.0~alpha~ gdImageGifPtr@Base 2.1.0~alpha~ gdImageGrayScale@Base 2.1.0~alpha~ gdImageInterlace@Base 2.1.0~alpha~ gdImageJpeg@Base 2.1.0~alpha~ gdImageJpegCtx@Base 2.1.0~alpha~ gdImageJpegPtr@Base 2.1.0~alpha~ gdImageLine@Base 2.1.0~alpha~ gdImageMeanRemoval@Base 2.1.0~alpha~ gdImageNegate@Base 2.1.0~alpha~ gdImageNeuQuant@Base 2.1.0~alpha~ gdImageOpenPolygon@Base 2.1.0~alpha~ gdImagePaletteCopy@Base 2.1.0~alpha~ gdImagePaletteToTrueColor@Base 2.1.0~alpha~ gdImagePixelate@Base 2.1.0~alpha~ gdImagePng@Base 2.1.0~alpha~ gdImagePngCtx@Base 2.1.0~alpha~ gdImagePngCtxEx@Base 2.1.0~alpha~ gdImagePngEx@Base 2.1.0~alpha~ gdImagePngPtr@Base 2.1.0~alpha~ gdImagePngPtrEx@Base 2.1.0~alpha~ gdImagePngToSink@Base 2.1.0~alpha~ gdImagePolygon@Base 2.1.0~alpha~ gdImageRectangle@Base 2.1.0~alpha~ gdImageRotateInterpolated@Base 2.1.0~alpha~ gdImageSaveAlpha@Base 2.1.0~alpha~ gdImageScale@Base 2.1.0~alpha~ gdImageScatter@Base 2.1.0~alpha~ gdImageScatterColor@Base 2.1.0~alpha~ gdImageScatterEx@Base 2.1.0~alpha~ gdImageSelectiveBlur@Base 2.1.0~alpha~ gdImageSetAntiAliased@Base 2.1.0~alpha~ gdImageSetAntiAliasedDontBlend@Base 2.1.0~alpha~ gdImageSetBrush@Base 2.1.0~alpha~ gdImageSetClip@Base 2.1.0~alpha~ gdImageSetInterpolationMethod@Base 2.1.0~alpha~ gdImageSetPixel@Base 2.1.0~alpha~ gdImageSetResolution@Base 2.1.0~alpha~ gdImageSetStyle@Base 2.1.0~alpha~ gdImageSetThickness@Base 2.1.0~alpha~ gdImageSetTile@Base 2.1.0~alpha~ gdImageSharpen@Base 2.1.0~alpha~ gdImageSmooth@Base 2.1.0~alpha~ gdImageSquareToCircle@Base 2.1.0~alpha~ gdImageString16@Base 2.1.0~alpha~ gdImageString@Base 2.1.0~alpha~ gdImageStringFT@Base 2.1.0~alpha~ gdImageStringFTCircle@Base 2.1.0~alpha~ gdImageStringFTEx@Base 2.1.0~alpha~ gdImageStringTTF@Base 2.1.0~alpha~ gdImageStringUp16@Base 2.1.0~alpha~ gdImageStringUp@Base 2.1.0~alpha~ gdImageTiff@Base 2.1.0~alpha~ gdImageTiffCtx@Base 2.1.0~alpha~ gdImageTiffPtr@Base 2.1.0~alpha~ gdImageTrueColorToPalette@Base 2.1.0~alpha~ gdImageTrueColorToPaletteSetMethod@Base 2.1.0~alpha~ gdImageTrueColorToPaletteSetQuality@Base 2.1.0~alpha~ gdImageWBMP@Base 2.1.0~alpha~ gdImageWBMPCtx@Base 2.1.0~alpha~ gdImageWBMPPtr@Base 2.1.0~alpha~ gdImageWebp@Base 2.1.0~alpha~ gdImageWebpCtx@Base 2.1.0~alpha~ gdImageWebpEx@Base 2.1.0~alpha~ gdImageWebpPtr@Base 2.1.0~alpha~ gdImageWebpPtrEx@Base 2.1.0~alpha~ gdImageXbmCtx@Base 2.1.0~alpha~ gdNewDynamicCtx@Base 2.1.0~alpha~ gdNewDynamicCtxEx@Base 2.1.0~alpha~ gdNewFileCtx@Base 2.1.0~alpha~ gdNewSSCtx@Base 2.1.0~alpha~ gdSetErrorMethod@Base 2.1.0~alpha~ gdTransformAffineBoundingBox@Base 2.1.0~alpha~ gdTransformAffineCopy@Base 2.1.0~alpha~ gdTransformAffineGetImage@Base 2.1.0~alpha~ debian/rules0000755000000000000000000000200212222240036010231 0ustar #!/usr/bin/make -f # -*- makefile -*- # Sample debian/rules that uses debhelper. # This file was originally written by Joey Hess and Craig Small. # As a special exception, when this file is copied by dh-make into a # dh-make output file, you may use that output file without restriction. # This special exception was added by Craig Small in version 0.37 of dh-make. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 export DPKG_GENSYMBOLS_CHECK_LEVEL=4 export DEB_BUILD_MAINT_OPTIONS = hardening=+all export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed %: dh $@ --with autoreconf override_dh_auto_configure: dh_auto_configure -- --disable-rpath --with-tiff=/usr --libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) override_dh_install: dh_install --fail-missing -Xlibgd.la override_dh_installdocs: dh_installdocs -plibgd2-xpm-dev -plibgd2-noxpm-dev --link-doc=libgd-dev dh_installdocs --remaining-packages override_dh_strip: dh_strip --dbg-package=libgd-dbg debian/control0000644000000000000000000001014612721575306010603 0ustar Source: libgd2 Section: graphics Priority: optional Maintainer: Ubuntu Developers XSBC-Original-Maintainer: GD team Uploaders: Ondřej Surý , Sean Finney Build-Depends: autotools-dev, debhelper (>= 9), libpng-dev, libz-dev, libjpeg-dev, libfreetype6-dev, libxpm-dev, libx11-dev, libxt-dev, libfontconfig-dev, libvpx-dev, libtiff-dev, dh-autoreconf, html2text Vcs-Git: git://anonscm.debian.org/git/collab-maint/libgd Vcs-Browser: http://anonscm.debian.org/?p=collab-maint/libgd.git;a=summary Standards-Version: 3.9.3 Homepage: http://www.libgd.org/ Package: libgd-tools Architecture: any Depends: ${shlibs:Depends}, ${perl:Depends}, ${misc:Depends} Suggests: libgd-dev Description: GD command line tools and example code GD is a graphics library. It allows your code to quickly draw images complete with lines, arcs, text, multiple colours, cut and paste from other images, flood fills, and write out the result as a PNG file. This is particularly useful in World Wide Web applications, where PNG is one of the formats accepted for inline images by most browsers. . This is some simple command line tools and example code that use the GD graphics library. Package: libgd-dev Architecture: any Multi-Arch: same Section: libdevel Depends: libgd3 (= ${binary:Version}), ${misc:Depends}, libpng-dev, libz-dev, libjpeg-dev, libfreetype6-dev, libxpm-dev, libx11-dev, libxt-dev, libfontconfig-dev, libvpx-dev, libtiff-dev Breaks: libgd2-xpm-dev (<< 2.1.0~), libgd2-noxpm-dev (<< 2.1.0~), libgd2-dev (<< 2.1.0~alpha1-2~) Replaces: libgd2-xpm-dev (<< 2.1.0~), libgd2-noxpm-dev (<< 2.1.0~), libgd2-dev (<< 2.1.0~alpha1-2~) Provides: libgd2-xpm-dev, libgd2-noxpm-dev, libgd2-dev Description: GD Graphics Library (development version) GD is a graphics library. It allows your code to quickly draw images complete with lines, arcs, text, multiple colours, cut and paste from other images, flood fills, and write out the result as a PNG file. This is particularly useful in World Wide Web applications, where PNG is one of the formats accepted for inline images by most browsers. . This is the full development version of the library. Package: libgd3 Architecture: any Multi-Arch: same Section: libs Pre-Depends: ${misc:Pre-Depends} Depends: ${shlibs:Depends}, ${misc:Depends} Suggests: libgd-tools Description: GD Graphics Library GD is a graphics library. It allows your code to quickly draw images complete with lines, arcs, text, multiple colours, cut and paste from other images, flood fills, and write out the result as a PNG file. This is particularly useful in World Wide Web applications, where PNG is one of the formats accepted for inline images by most browsers. . This is the runtime package of the library. Package: libgd-dbg Architecture: any Multi-Arch: same Section: debug Priority: extra Recommends: gdb Depends: ${misc:Depends}, libgd3 (= ${binary:Version}) | libgd-tools (= ${binary:Version}) Description: Debug symbols for GD Graphics Library GD is a graphics library. It allows your code to quickly draw images complete with lines, arcs, text, multiple colours, cut and paste from other images, flood fills, and write out the result as a PNG file. This is particularly useful in World Wide Web applications, where PNG is one of the formats accepted for inline images by most browsers. . These are the debug symbols for the library and tools. Package: libgd2-xpm-dev Architecture: all Section: oldlibs Priority: extra Depends: ${misc:Depends}, libgd-dev Multi-Arch: foreign Description: GD Graphics Library (transitional package) This is a dummy transition package that can be safely removed once no package depend on it. Package: libgd2-noxpm-dev Architecture: all Section: oldlibs Priority: extra Depends: ${misc:Depends}, libgd-dev Multi-Arch: foreign Description: GD Graphics Library (transitional package) This is a dummy transition package that can be safely removed once no package depend on it. debian/watch0000644000000000000000000000032612222240036010211 0ustar # run the "uscan" command to check for upstream updates and more. version=3 opts="uversionmangle=s/RC/~rc/,dversionmangle=s/\~dfsg$//" \ https://bitbucket.org/libgd/gd-libgd/downloads/gd-([\.0-9].*).tar.xz debian debian/libgd2-noxpm-dev.lintian-overrides0000644000000000000000000000013212222240036015611 0ustar libgd2-noxpm-dev: virtual-package-depends-without-real-package-depends depends: libgd-dev debian/gbp.conf0000644000000000000000000000023012222240036010571 0ustar # Configuration file for git-buildpackage and friends [DEFAULT] pristine-tar = True sign-tags = True debian-branch = master upstream-branch = upstream debian/patches/0000755000000000000000000000000013435567204010626 5ustar debian/patches/CVE-2013-7456.patch0000644000000000000000000000265112737771701013261 0ustar From 4f65a3e4eedaffa1efcf9ee1eb08f0b504fbc31a Mon Sep 17 00:00:00 2001 From: Chris Reuter Date: Mon, 23 Sep 2013 18:03:08 -0400 Subject: [PATCH] Fixed memory overrun bug in gdImageScaleTwoPass _gdContributionsCalc would compute a window size and then adjust the left and right positions of the window to make a window within that size. However, it was storing the values in the struct *before* it made the adjustment. This change fixes that. --- src/gd_interpolation.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gd_interpolation.c b/src/gd_interpolation.c index 43891e6..71cc150 100644 --- a/src/gd_interpolation.c +++ b/src/gd_interpolation.c @@ -953,9 +953,6 @@ static inline LineContribType *_gdContributionsCalc(unsigned int line_size, unsi double dTotalWeight = 0.0; int iSrc; - res->ContribRow[u].Left = iLeft; - res->ContribRow[u].Right = iRight; - /* Cut edge points to fit in filter window in case of spill-off */ if (iRight - iLeft + 1 > windows_size) { if (iLeft < ((int)src_size - 1 / 2)) { @@ -965,6 +962,9 @@ static inline LineContribType *_gdContributionsCalc(unsigned int line_size, unsi } } + res->ContribRow[u].Left = iLeft; + res->ContribRow[u].Right = iRight; + for (iSrc = iLeft; iSrc <= iRight; iSrc++) { dTotalWeight += (res->ContribRow[u].Weights[iSrc-iLeft] = scale_f_d * (*pFilter)(scale_f_d * (dCenter - (double)iSrc))); } debian/patches/CVE-2019-6978.patch0000644000000000000000000001733313435567204013277 0ustar Backport of: From 553702980ae89c83f2d6e254d62cf82e204956d0 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Thu, 17 Jan 2019 11:54:55 +0100 Subject: [PATCH] Fix #492: Potential double-free in gdImage*Ptr() Whenever `gdImage*Ptr()` calls `gdImage*Ctx()` and the latter fails, we must not call `gdDPExtractData()`; otherwise a double-free would happen. Since `gdImage*Ctx()` are void functions, and we can't change that for BC reasons, we're introducing static helpers which are used internally. We're adding a regression test for `gdImageJpegPtr()`, but not for `gdImageGifPtr()` and `gdImageWbmpPtr()` since we don't know how to trigger failure of the respective `gdImage*Ctx()` calls. This potential security issue has been reported by Solmaz Salimi (aka. Rooney). --- src/gd_gif_out.c | 18 +++++++++++++++--- src/gd_jpeg.c | 20 ++++++++++++++++---- src/gd_wbmp.c | 21 ++++++++++++++++++--- tests/jpeg/.gitignore | 1 + tests/jpeg/CMakeLists.txt | 1 + tests/jpeg/Makemodule.am | 3 ++- tests/jpeg/jpeg_ptr_double_free.c | 31 +++++++++++++++++++++++++++++++ 7 files changed, 84 insertions(+), 11 deletions(-) create mode 100644 tests/jpeg/jpeg_ptr_double_free.c Index: libgd2-2.1.0/src/gd_gif_out.c =================================================================== --- libgd2-2.1.0.orig/src/gd_gif_out.c 2019-02-27 14:42:21.181370198 -0500 +++ libgd2-2.1.0/src/gd_gif_out.c 2019-02-27 15:09:32.348991660 -0500 @@ -93,13 +93,18 @@ static void char_init(GifCtx *ctx); static void char_out(int c, GifCtx *ctx); static void flush_char(GifCtx *ctx); +static int _gdImageGifCtx(gdImagePtr im, gdIOCtxPtr out); + BGD_DECLARE(void *) gdImageGifPtr(gdImagePtr im, int *size) { void *rv; gdIOCtx *out = gdNewDynamicCtx(2048, NULL); if (out == NULL) return NULL; - gdImageGifCtx(im, out); - rv = gdDPExtractData(out, size); + if (!_gdImageGifCtx(im, out)) { + rv = gdDPExtractData(out, size); + } else { + rv = NULL; + } out->gd_free(out); return rv; } @@ -114,6 +119,12 @@ BGD_DECLARE(void) gdImageGif(gdImagePtr BGD_DECLARE(void) gdImageGifCtx(gdImagePtr im, gdIOCtxPtr out) { + _gdImageGifCtx(im, out); +} + +/* returns 0 on success, 1 on failure */ +static int _gdImageGifCtx(gdImagePtr im, gdIOCtxPtr out) +{ gdImagePtr pim = 0, tim = im; int interlace, BitsPerPixel; interlace = im->interlace; @@ -124,7 +135,7 @@ BGD_DECLARE(void) gdImageGifCtx(gdImageP based temporary image. */ pim = gdImageCreatePaletteFromTrueColor(im, 1, 256); if(!pim) { - return; + return 1; } tim = pim; } @@ -140,6 +151,8 @@ BGD_DECLARE(void) gdImageGifCtx(gdImageP /* Destroy palette based temporary image. */ gdImageDestroy( pim); } + + return 0; } BGD_DECLARE(void *) gdImageGifAnimBeginPtr(gdImagePtr im, int *size, int GlobalCM, int Loops) Index: libgd2-2.1.0/src/gd_jpeg.c =================================================================== --- libgd2-2.1.0.orig/src/gd_jpeg.c 2019-02-27 14:42:21.181370198 -0500 +++ libgd2-2.1.0/src/gd_jpeg.c 2019-02-27 14:42:21.177370185 -0500 @@ -118,6 +118,8 @@ static void fatal_jpeg_error(j_common_pt exit(99); } +static int _gdImageJpegCtx(gdImagePtr im, gdIOCtx *outfile, int quality); + /* * Write IM to OUTFILE as a JFIF-formatted JPEG image, using quality * QUALITY. If QUALITY is in the range 0-100, increasing values @@ -140,8 +142,11 @@ BGD_DECLARE(void *) gdImageJpegPtr(gdIma void *rv; gdIOCtx *out = gdNewDynamicCtx(2048, NULL); if (out == NULL) return NULL; - gdImageJpegCtx(im, out, quality); - rv = gdDPExtractData(out, size); + if (!_gdImageJpegCtx(im, out, quality)) { + rv = gdDPExtractData(out, size); + } else { + rv = NULL; + } out->gd_free(out); return rv; } @@ -150,6 +155,12 @@ void jpeg_gdIOCtx_dest(j_compress_ptr ci BGD_DECLARE(void) gdImageJpegCtx(gdImagePtr im, gdIOCtx *outfile, int quality) { + _gdImageJpegCtx(im, outfile, quality); +} + +/* returns 0 on success, 1 on failure */ +static int _gdImageJpegCtx(gdImagePtr im, gdIOCtx *outfile, int quality) +{ struct jpeg_compress_struct cinfo; struct jpeg_error_mgr jerr; int i, j, jidx; @@ -183,7 +194,7 @@ BGD_DECLARE(void) gdImageJpegCtx(gdImage if(row) { gdFree(row); } - return; + return 1; } cinfo.err->emit_message = jpeg_emit_message; @@ -220,7 +231,7 @@ BGD_DECLARE(void) gdImageJpegCtx(gdImage if(row == 0) { gd_error("gd-jpeg: error: unable to allocate JPEG row structure: gdCalloc returns NULL\n"); jpeg_destroy_compress(&cinfo); - return; + return 1; } rowptr[0] = row; @@ -297,6 +308,7 @@ BGD_DECLARE(void) gdImageJpegCtx(gdImage jpeg_finish_compress(&cinfo); jpeg_destroy_compress(&cinfo); gdFree(row); + return 0; } BGD_DECLARE(gdImagePtr) gdImageCreateFromJpeg(FILE *inFile) Index: libgd2-2.1.0/src/gd_wbmp.c =================================================================== --- libgd2-2.1.0.orig/src/gd_wbmp.c 2019-02-27 14:42:21.181370198 -0500 +++ libgd2-2.1.0/src/gd_wbmp.c 2019-02-27 14:42:21.181370198 -0500 @@ -82,6 +82,8 @@ int gd_getin(void *in) return (gdGetC((gdIOCtx *)in)); } +static int _gdImageWBMPCtx(gdImagePtr image, int fg, gdIOCtx *out); + /* gdImageWBMPCtx * -------------- * Write the image as a wbmp file @@ -93,13 +95,19 @@ int gd_getin(void *in) */ BGD_DECLARE(void) gdImageWBMPCtx(gdImagePtr image, int fg, gdIOCtx *out) { + _gdImageWBMPCtx(image, fg, out); +} + +/* returns 0 on success, 1 on failure */ +static int _gdImageWBMPCtx(gdImagePtr image, int fg, gdIOCtx *out) +{ int x, y, pos; Wbmp *wbmp; /* create the WBMP */ if((wbmp = createwbmp(gdImageSX(image), gdImageSY(image), WBMP_WHITE)) == NULL) { gd_error("Could not create WBMP\n"); - return; + return 1; } /* fill up the WBMP structure */ @@ -115,11 +123,15 @@ BGD_DECLARE(void) gdImageWBMPCtx(gdImage /* write the WBMP to a gd file descriptor */ if(writewbmp(wbmp, &gd_putout, out)) { + freewbmp(wbmp); gd_error("Could not save WBMP\n"); + return 1; } /* des submitted this bugfix: gdFree the memory. */ freewbmp(wbmp); + + return 0; } /* gdImageCreateFromWBMPCtx @@ -206,8 +218,11 @@ BGD_DECLARE(void *) gdImageWBMPPtr(gdIma void *rv; gdIOCtx *out = gdNewDynamicCtx(2048, NULL); if (out == NULL) return NULL; - gdImageWBMPCtx(im, fg, out); - rv = gdDPExtractData(out, size); + if (!_gdImageWBMPCtx(im, fg, out)) { + rv = gdDPExtractData(out, size); + } else { + rv = NULL; + } out->gd_free(out); return rv; } Index: libgd2-2.1.0/tests/jpeg/CMakeLists.txt =================================================================== --- libgd2-2.1.0.orig/tests/jpeg/CMakeLists.txt 2019-02-27 14:42:21.181370198 -0500 +++ libgd2-2.1.0/tests/jpeg/CMakeLists.txt 2019-02-27 14:42:21.181370198 -0500 @@ -1,6 +1,7 @@ SET(TESTS_FILES jpeg_im2im + jpeg_ptr_double_free jpeg_null jpeg_read jpeg_empty_file Index: libgd2-2.1.0/tests/jpeg/jpeg_ptr_double_free.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ libgd2-2.1.0/tests/jpeg/jpeg_ptr_double_free.c 2019-02-27 14:42:21.181370198 -0500 @@ -0,0 +1,31 @@ +/** + * Test that failure to convert to JPEG returns NULL + * + * We are creating an image, set its width to zero, and pass this image to + * `gdImageJpegPtr()` which is supposed to fail, and as such should return NULL. + * + * See also + */ + + +#include "gd.h" +#include "gdtest.h" + + +int main() +{ + gdImagePtr src, dst; + int size; + + src = gdImageCreateTrueColor(1, 10); + gdTestAssert(src != NULL); + + src->sx = 0; /* this hack forces gdImageJpegPtr() to fail */ + + dst = gdImageJpegPtr(src, &size, 0); + gdTestAssert(dst == NULL); + + gdImageDestroy(src); + + return gdNumFailures(); +} debian/patches/series0000644000000000000000000000140113435563313012034 0ustar gdlib-config-uses-pkgconfig.patch fix-compiled-in-version.patch subdir-objects.patch CVE-2014-2497.patch CVE-2014-9709-1.patch CVE-2014-9709-2.patch CVE-2015-8874.patch CVE-2015-8877.patch CVE-2016-3074.patch CVE-2013-7456.patch CVE-2016-5116.patch CVE-2016-5766.patch CVE-2016-6128.patch CVE-2016-6161.patch CVE-2016-6132.patch CVE-2016-6207.patch CVE-2016-6214.patch CVE-2016-7568.patch CVE-2016-8670.patch CVE-2016-6911.patch CVE-2016-6906-pre1.patch CVE-2016-6906-pre2.patch CVE-2016-6906-1.patch CVE-2016-6906-2.patch CVE-2016-6912.patch CVE-2016-9317.patch CVE-2016-9933.patch CVE-2016-10166.patch CVE-2016-10167.patch CVE-2016-10168.patch CVE-2017-7890.patch CVE-2017-6362.patch CVE-2018-1000222.patch CVE-2018-5711.patch CVE-2019-6977.patch CVE-2019-6978.patch debian/patches/CVE-2016-10167.patch0000644000000000000000000000330013055314463013315 0ustar From fe9ed49dafa993e3af96b6a5a589efeea9bfb36f Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Tue, 16 Aug 2016 18:23:36 +0200 Subject: [PATCH] Fix DOS vulnerability in gdImageCreateFromGd2Ctx() We must not pretend that there are image data if there are none. Instead we fail reading the image file gracefully. --- src/gd_gd2.c | 14 ++++++-------- tests/gd2/.gitignore | 1 + tests/gd2/CMakeLists.txt | 1 + tests/gd2/Makemodule.am | 7 +++++-- tests/gd2/too_few_image_data.c | 22 ++++++++++++++++++++++ tests/gd2/too_few_image_data.gd2 | Bin 0 -> 1050 bytes 6 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 tests/gd2/too_few_image_data.c create mode 100644 tests/gd2/too_few_image_data.gd2 Index: libgd2-2.1.0/src/gd_gd2.c =================================================================== --- libgd2-2.1.0.orig/src/gd_gd2.c 2017-02-28 10:37:22.147272721 -0500 +++ libgd2-2.1.0/src/gd_gd2.c 2017-02-28 10:37:22.147272721 -0500 @@ -386,18 +386,16 @@ if (im->trueColor) { if (!gdGetInt (&im->tpixels[y][x], in)) { - /*printf("EOF while reading\n"); */ - /*gdImageDestroy(im); */ - /*return 0; */ - im->tpixels[y][x] = 0; + gd_error("gd2: EOF while reading\n"); + gdImageDestroy(im); + return NULL; } } else { int ch; if (!gdGetByte (&ch, in)) { - /*printf("EOF while reading\n"); */ - /*gdImageDestroy(im); */ - /*return 0; */ - ch = 0; + gd_error("gd2: EOF while reading\n"); + gdImageDestroy(im); + return NULL; } im->pixels[y][x] = ch; } debian/patches/CVE-2016-6906-pre1.patch0000644000000000000000000000243713055314376014125 0ustar From 71f2ff370e5101c72e89fe4c84c103634a0e7ed9 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Tue, 19 Jul 2016 11:40:19 +0200 Subject: [PATCH] Fix #264: TGA warning coverity We fix the unintended sign extension issue #150385 by declaring encoded_pixels as int, and the logical vs. bitwise operator issue #150382 by using the proper operator. --- src/gd_tga.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) Index: libgd2-2.1.1/src/gd_tga.c =================================================================== --- libgd2-2.1.1.orig/src/gd_tga.c 2017-02-28 10:21:25.263953073 -0500 +++ libgd2-2.1.1/src/gd_tga.c 2017-02-28 10:21:25.259953025 -0500 @@ -196,7 +196,7 @@ int buffer_caret = 0; int bitmap_caret = 0; int i = 0; - uint8_t encoded_pixels; + int encoded_pixels; if(overflow2(tga->width, tga->height)) { return -1; @@ -291,7 +291,7 @@ while( bitmap_caret < image_block_size ) { if ((decompression_buffer[buffer_caret] & TGA_RLE_FLAG) == TGA_RLE_FLAG) { - encoded_pixels = ( ( decompression_buffer[ buffer_caret ] & !TGA_RLE_FLAG ) + 1 ); + encoded_pixels = ( ( decompression_buffer[ buffer_caret ] & ~TGA_RLE_FLAG ) + 1 ); buffer_caret++; if ((bitmap_caret + (encoded_pixels * pixel_block_size)) >= image_block_size) { debian/patches/CVE-2016-10168.patch0000644000000000000000000000314313055314466013326 0ustar From 69d2fd2c597ffc0c217de1238b9bf4d4bceba8e6 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sat, 17 Dec 2016 17:06:58 +0100 Subject: [PATCH] Fix #354: Signed Integer Overflow gd_io.c GD2 stores the number of horizontal and vertical chunks as words (i.e. 2 byte unsigned). These values are multiplied and assigned to an int when reading the image, what can cause integer overflows. We have to avoid that, and also make sure that either chunk count is actually greater than zero. If illegal chunk counts are detected, we bail out from reading the image. --- src/gd_gd2.c | 4 ++++ tests/gd2/.gitignore | 1 + tests/gd2/CMakeLists.txt | 1 + tests/gd2/Makemodule.am | 3 +++ tests/gd2/bug00354.c | 32 ++++++++++++++++++++++++++++++++ tests/gd2/bug00354a.gd2 | Bin 0 -> 92 bytes tests/gd2/bug00354b.gd2 | Bin 0 -> 18 bytes 7 files changed, 41 insertions(+) create mode 100644 tests/gd2/bug00354.c create mode 100644 tests/gd2/bug00354a.gd2 create mode 100644 tests/gd2/bug00354b.gd2 Index: libgd2-2.1.1/src/gd_gd2.c =================================================================== --- libgd2-2.1.1.orig/src/gd_gd2.c 2017-02-28 10:29:28.741672472 -0500 +++ libgd2-2.1.1/src/gd_gd2.c 2017-02-28 10:29:28.741672472 -0500 @@ -153,6 +153,10 @@ GD2_DBG (printf ("%d Chunks vertically\n", *ncy)); if (gd2_compressed (*fmt)) { + if (*ncx <= 0 || *ncy <= 0 || *ncx > INT_MAX / *ncy) { + GD2_DBG(printf ("Illegal chunk counts: %d * %d\n", *ncx, *ncy)); + goto fail1; + } nc = (*ncx) * (*ncy); GD2_DBG (printf ("Reading %d chunk index entries\n", nc)); debian/patches/CVE-2016-3074.patch0000644000000000000000000000231712721575036013247 0ustar From 2bb97f407c1145c850416a3bfbcc8cf124e68a19 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 16 Apr 2016 03:51:22 -0400 Subject: [PATCH] gd2: handle corrupt images better (CVE-2016-3074) Make sure we do some range checking on corrupted chunks. Thanks to Hans Jerry Illikainen for indepth report and reproducer information. Made for easy test case writing :). --- .gitignore | 1 + src/gd_gd2.c | 2 ++ tests/Makefile.am | 3 ++- tests/gd2/gd2_read_corrupt.c | 25 +++++++++++++++++++++++++ tests/gd2/invalid_neg_size.gd2 | Bin 0 -> 1676 bytes 5 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/gd2/gd2_read_corrupt.c create mode 100644 tests/gd2/invalid_neg_size.gd2 Index: libgd2-2.1.0/src/gd_gd2.c =================================================================== --- libgd2-2.1.0.orig/src/gd_gd2.c 2016-05-26 09:29:00.574149713 -0400 +++ libgd2-2.1.0/src/gd_gd2.c 2016-05-26 09:29:00.574149713 -0400 @@ -167,6 +167,8 @@ if (gdGetInt (&cidx[i].size, in) != 1) { goto fail2; }; + if (cidx[i].offset < 0 || cidx[i].size < 0) + goto fail2; }; *chunkIdx = cidx; }; debian/patches/CVE-2016-6161.patch0000644000000000000000000000357412737771753013270 0ustar From 82b80dcb70a7ca8986125ff412bceddafc896842 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 14 May 2016 02:13:15 -0400 Subject: [PATCH] gif: avoid out-of-bound reads of masks array #209 When given invalid inputs, we might be fed the EOF marker before it is actually the EOF. The gif logic assumes once it sees the EOF marker, there won't be any more data, so it leaves the cur_bits index possibly negative. So when we get more data, we underflow the masks array. Flag it so we don't try to output anything more. The image is invalid, so we shouldn't be truncating any valid inputs. This fixes #209. --- src/gd_gif_out.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) Index: libgd2-2.1.0/src/gd_gif_out.c =================================================================== --- libgd2-2.1.0.orig/src/gd_gif_out.c 2016-07-08 14:41:42.343361086 -0400 +++ libgd2-2.1.0/src/gd_gif_out.c 2016-07-08 14:41:42.343361086 -0400 @@ -1000,15 +1000,23 @@ * code in turn. When the buffer fills up empty it and start over. */ -static unsigned long masks[] = { +static const unsigned long masks[] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF }; +/* Arbitrary value to mark output is done. When we see EOFCode, then we don't + * expect to see any more data. If we do (e.g. corrupt image inputs), cur_bits + * might be negative, so flag it to return early. + */ +#define CUR_BITS_FINISHED -1000 + static void output(code_int code, GifCtx *ctx) { + if (ctx->cur_bits == CUR_BITS_FINISHED) + return; ctx->cur_accum &= masks[ctx->cur_bits]; if(ctx->cur_bits > 0) { @@ -1050,6 +1058,8 @@ ctx->cur_accum >>= 8; ctx->cur_bits -= 8; } + /* Flag that it's done to prevent re-entry. */ + ctx->cur_bits = CUR_BITS_FINISHED; flush_char(ctx); } debian/patches/CVE-2018-5711.patch0000644000000000000000000000234113337577005013250 0ustar From 3b50e238b2d7ec2a3d46aa428694e02479477b7a Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Wed, 29 Nov 2017 18:52:33 +0100 Subject: [PATCH 1/1] Fixed bug #75571: Potential infinite loop in gdImageCreateFromGifCtx Due to a signedness confusion in `GetCode_` a corrupt GIF file can trigger an infinite loop. Furthermore we make sure that a GIF without any palette entries is treated as invalid *after* open palette entries have been removed. (cherry picked from commit 8d6e9588671136837533fe3785657c31c5b52767) diff --git a/src/gd_gif_in.c b/src/gd_gif_in.c index 5be3d47..0b9ee1a 100644 --- a/src/gd_gif_in.c +++ b/src/gd_gif_in.c @@ -270,12 +270,6 @@ terminated: if(!im) { return 0; } - - if(!im->colorsTotal) { - gdImageDestroy(im); - return 0; - } - /* Check for open colors at the end, so * we can reduce colorsTotal and ultimately * BitsPerPixel */ @@ -287,6 +281,10 @@ terminated: } } + if(!im->colorsTotal) { + gdImageDestroy(im); + return 0; + } return im; } @@ -383,7 +381,7 @@ static int GetCode_(gdIOCtx *fd, CODE_STATIC_DATA *scd, int code_size, int flag, int *ZeroDataBlockP) { int i, j, ret; - unsigned char count; + int count; if(flag) { scd->curbit = 0; debian/patches/CVE-2017-6362.patch0000644000000000000000000002154713153360137013253 0ustar Backported of: From 56ce6ef068b954ad28379e83cca04feefc51320c Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sun, 27 Aug 2017 17:18:34 +0200 Subject: [PATCH] Fix #381: libgd double-free vulnerability The issue is that `gdImagePngCtxEx` (which is called by `gdImagePngPtr` and the other PNG output functions to do the real work) does not return whether it succeeded or failed, so this is not checked in `gdImagePngPtr` and the function wrongly assumes everything is okay, which is not, in this case, because the palette image contains no palette entries. We can't change the signature of `gdImagePngCtxEx` for API compatibility reasons, so we introduce the static helper `_gdImagePngCtxEx` which returns success respective failure, so `gdImagePngPtr` and `gdImagePngPtrEx` can check the return value. We leave it solely to libpng for now to report warnings regarding the failing write. CVE-2017-6362 (cherry picked from commit 2207e3c88a06a5c42230907554ab1e9f2ec021ea) --- src/gd_png.c | 40 +++++++++++++++++++++++++++++++--------- tests/Makefile.am | 5 +++++ tests/png/CMakeLists.txt | 2 ++ tests/png/bug00381_1.c | 31 +++++++++++++++++++++++++++++++ tests/png/bug00381_2.c | 37 +++++++++++++++++++++++++++++++++++++ 5 files changed, 106 insertions(+), 9 deletions(-) create mode 100644 tests/png/bug00381_1.c create mode 100644 tests/png/bug00381_2.c diff --git a/src/gd_png.c b/src/gd_png.c index 3d381e9..35cf6e4 100644 --- a/src/gd_png.c +++ b/src/gd_png.c @@ -490,13 +490,18 @@ BGD_DECLARE(void) gdImagePng (gdImagePtr im, FILE * outFile) out->gd_free (out); } +static int _gdImagePngCtxEx(gdImagePtr im, gdIOCtx * outfile, int level); + BGD_DECLARE(void *) gdImagePngPtr (gdImagePtr im, int *size) { void *rv; gdIOCtx *out = gdNewDynamicCtx (2048, NULL); if (out == NULL) return NULL; - gdImagePngCtxEx (im, out, -1); - rv = gdDPExtractData (out, size); + if (!_gdImagePngCtxEx (im, out, -1)) { + rv = gdDPExtractData (out, size); + } else { + rv = NULL; + } out->gd_free (out); return rv; } @@ -506,8 +511,11 @@ BGD_DECLARE(void *) gdImagePngPtrEx (gdImagePtr im, int *size, int level) void *rv; gdIOCtx *out = gdNewDynamicCtx (2048, NULL); if (out == NULL) return NULL; - gdImagePngCtxEx (im, out, level); - rv = gdDPExtractData (out, size); + if (!_gdImagePngCtxEx (im, out, level)) { + rv = gdDPExtractData (out, size); + } else { + rv = NULL; + } out->gd_free (out); return rv; } @@ -518,11 +526,16 @@ BGD_DECLARE(void) gdImagePngCtx (gdImagePtr im, gdIOCtx * outfile) gdImagePngCtxEx (im, outfile, -1); } +BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level) +{ + _gdImagePngCtxEx(im, outfile, level); +} /* This routine is based in part on code from Dale Lutz (Safe Software Inc.) * and in part on demo code from Chapter 15 of "PNG: The Definitive Guide" * (http://www.libpng.org/pub/png/book/). */ -BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level) +/* returns 0 on success, 1 on failure */ +static int _gdImagePngCtxEx(gdImagePtr im, gdIOCtx * outfile, int level) { int i, j, bit_depth = 0, interlace_type; int width = im->sx; @@ -540,10 +553,11 @@ BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level) #ifdef PNG_SETJMP_SUPPORTED jmpbuf_wrapper jbw; #endif + int ret = 0; /* width or height of value 0 is invalid in IHDR; see http://www.w3.org/TR/PNG-Chunks.html */ - if (width == 0 || height ==0) return; + if (width == 0 || height ==0) return 1; #ifdef PNG_SETJMP_SUPPORTED png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, @@ -554,21 +568,21 @@ BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level) #endif if (png_ptr == NULL) { gd_error("gd-png error: cannot allocate libpng main struct\n"); - return; + return 1; } info_ptr = png_create_info_struct (png_ptr); if (info_ptr == NULL) { gd_error("gd-png error: cannot allocate libpng info struct\n"); png_destroy_write_struct (&png_ptr, (png_infopp) NULL); - return; + return 1; } #ifdef PNG_SETJMP_SUPPORTED if (setjmp(jbw.jmpbuf)) { gd_error("gd-png error: setjmp returns error condition\n"); png_destroy_write_struct (&png_ptr, &info_ptr); - return; + return 1; } #endif @@ -620,6 +634,7 @@ BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level) } if (colors == 0) { gd_error("gd-png error: no colors in palette\n"); + ret = 1; goto bail; } if (colors < im->colorsTotal) { @@ -751,11 +766,13 @@ BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level) png_bytep *prow_pointers; int saveAlphaFlag = im->saveAlphaFlag; if (overflow2(sizeof (png_bytep), height)) { + ret = 1; goto bail; } row_pointers = gdMalloc (sizeof (png_bytep) * height); if (row_pointers == NULL) { gd_error("gd-png error: unable to allocate row_pointers\n"); + ret = 1; goto bail; } prow_pointers = row_pointers; @@ -767,6 +784,7 @@ BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level) gdFree (row_pointers[i]); /* 2.0.29: memory leak TBB */ gdFree(row_pointers); + ret = 1; goto bail; } pOutputRow = *prow_pointers++; @@ -800,11 +818,13 @@ BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level) if (remap) { png_bytep *row_pointers; if (overflow2(sizeof (png_bytep), height)) { + ret = 1; goto bail; } row_pointers = gdMalloc (sizeof (png_bytep) * height); if (row_pointers == NULL) { gd_error("gd-png error: unable to allocate row_pointers\n"); + ret = 1; goto bail; } for (j = 0; j < height; ++j) { @@ -814,6 +834,7 @@ BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level) gdFree (row_pointers[i]); /* TBB: memory leak */ gdFree (row_pointers); + ret = 1; goto bail; } for (i = 0; i < width; ++i) @@ -834,6 +855,7 @@ BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level) /* 1.6.3: maybe we should give that memory BACK! TBB */ bail: png_destroy_write_struct (&png_ptr, &info_ptr); + return ret; } diff --git a/tests/Makefile.am b/tests/Makefile.am index 76d3860..7fd3b6d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -87,6 +87,8 @@ EXTRA_PROGRAMS = \ png/png_null \ png/bug00033 \ png/bug00193 \ + png/bug00381_1 \ + png/bug00381_2 \ png/bug00011 \ png/bug00088 \ png/png_resolution \ @@ -177,6 +179,8 @@ check_PROGRAMS += \ png/png_null \ png/bug00033 \ png/bug00193 \ + png/bug00381_1 \ + png/bug00381_2 \ png/bug00011 \ png/bug00088 \ png/png_resolution \ @@ -227,6 +231,7 @@ EXTRA_DIST = \ png/bug00033.png \ png/bug00088_2_exp.png \ png/bug00088_1.png \ + png/bug00381_2.gd \ png/emptyfile \ gdimageline/gdimageline_aa_b_0_exp.png \ gdimageline/gdimageline_aa_c_0_exp.png \ diff --git a/tests/png/CMakeLists.txt b/tests/png/CMakeLists.txt index dd0b4c4..3640886 100644 --- a/tests/png/CMakeLists.txt +++ b/tests/png/CMakeLists.txt @@ -8,6 +8,8 @@ SET(TESTS_FILES bug00086 bug00088 bug00193 + bug00381_1 + bug00381_2 ) FOREACH(test_name ${TESTS_FILES}) diff --git a/tests/png/bug00381_1.c b/tests/png/bug00381_1.c new file mode 100644 index 0000000..48beca8 --- /dev/null +++ b/tests/png/bug00381_1.c @@ -0,0 +1,31 @@ +/** + * Test that failure to convert to PNG returns NULL + * + * We are creating a palette image without allocating any colors in the palette, + * and pass this image to `gdImagePngPtr()` which is supposed to fail, and as + * such should return NULL. + * + * See also + */ + + +#include "gd.h" +#include "gdtest.h" + + +int main() +{ + gdImagePtr im; + void *data; + int size = 0; + + im = gdImageCreate(100, 100); + gdTestAssert(im != NULL); + + data = gdImagePngPtr(im, &size); + gdTestAssert(data == NULL); + + gdImageDestroy(im); + + return 0; +} diff --git a/tests/png/bug00381_2.c b/tests/png/bug00381_2.c new file mode 100644 index 0000000..dc57312 --- /dev/null +++ b/tests/png/bug00381_2.c @@ -0,0 +1,37 @@ +/** + * Test that failure to convert to PNG returns NULL + * + * We are reading a palette image without any colors in the palette, and pass + * this image to `gdImagePngPtr()` which is supposed to fail, and as such should + * return NULL. + * + * See also + */ + + +#include "gd.h" +#include "gdtest.h" + + +int main() +{ + gdImagePtr im; + FILE *fp; + char path[1024]; + void *data; + int size = 0; + + sprintf(path, "%s/png/%s", GDTEST_TOP_DIR, "bug00381_2.gd"); + fp = fopen(path, "rb"); + gdTestAssert(fp != NULL); + im = gdImageCreateFromGd(fp); + gdTestAssert(im != NULL); + fclose(fp); + + data = gdImagePngPtr(im, &size); + gdTestAssert(data == NULL); + + gdImageDestroy(im); + + return 0; +} -- 2.7.4 debian/patches/CVE-2014-9709-2.patch0000644000000000000000000000172212721574666013426 0ustar From 81e9a993f2893d651d225646378e3fd1b7465467 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 16 Dec 2014 18:29:47 +0100 Subject: [PATCH] move overflow test outside the loop for perf --- src/gd_gif_in.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) Index: libgd2-2.1.0/src/gd_gif_in.c =================================================================== --- libgd2-2.1.0.orig/src/gd_gif_in.c 2016-05-26 09:27:17.196772359 -0400 +++ libgd2-2.1.0/src/gd_gif_in.c 2016-05-26 09:27:17.192772306 -0400 @@ -410,13 +410,12 @@ scd->lastbit = (2 + count) * 8; } - ret = 0; - for (i = scd->curbit, j = 0; j < code_size; ++i, ++j) { - if (i < CSD_BUF_SIZE * 8) { + if ((scd->curbit + code_size - 1) >= (CSD_BUF_SIZE * 8)) { + ret = -1; + } else { + ret = 0; + for (i = scd->curbit, j = 0; j < code_size; ++i, ++j) { ret |= ((scd->buf[i / 8] & (1 << (i % 8))) != 0) << j; - } else { - ret = -1; - break; } } debian/patches/CVE-2016-6132.patch0000644000000000000000000000674512752356447013265 0ustar Description: fix out of bounds read in TGA file parsing Origin: backport, https://github.com/libgd/libgd/commit/ead349e99868303b37f5e6e9d9d680c9dc71ff8d Origin: backport, https://github.com/libgd/libgd/commit/981060efd6415ed9a08a6aa343e6e195bf65fb47 Origin: backport, https://github.com/libgd/libgd/commit/ff0234f4da6d1116c0baa66eebd8497526f7a5d9 Bug: https://github.com/libgd/libgd/issues/247 Bug: https://github.com/libgd/libgd/issues/248 Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=829694 Index: libgd2-2.1.1/src/gd_tga.c =================================================================== --- libgd2-2.1.1.orig/src/gd_tga.c 2016-08-09 09:32:01.411252965 -0400 +++ libgd2-2.1.1/src/gd_tga.c 2016-08-09 09:33:30.128462897 -0400 @@ -200,7 +200,6 @@ int buffer_caret = 0; int bitmap_caret = 0; int i = 0; - int j = 0; uint8_t encoded_pixels; if(overflow2(tga->width, tga->height)) { @@ -247,7 +246,11 @@ return -1; } - gdGetBuf(conversion_buffer, image_block_size, ctx); + if (gdGetBuf(conversion_buffer, image_block_size, ctx) != image_block_size) { + gd_error("gd-tga: premature end of image data\n"); + gdFree(conversion_buffer); + return -1; + } while (buffer_caret < image_block_size) { tga->bitmap[buffer_caret] = (int) conversion_buffer[buffer_caret]; @@ -268,12 +271,17 @@ } conversion_buffer = (unsigned char *) gdMalloc(image_block_size * sizeof(unsigned char)); if (conversion_buffer == NULL) { + gd_error("gd-tga: premature end of image data\n"); gdFree( decompression_buffer ); gdFree( conversion_buffer ); return -1; } - gdGetBuf( conversion_buffer, image_block_size, ctx ); + if (gdGetBuf(conversion_buffer, image_block_size, ctx) != image_block_size) { + gdFree(conversion_buffer); + gdFree(decompression_buffer); + return -1; + } buffer_caret = 0; @@ -285,27 +293,36 @@ buffer_caret = 0; while( bitmap_caret < image_block_size ) { - + if ((decompression_buffer[buffer_caret] & TGA_RLE_FLAG) == TGA_RLE_FLAG) { - encoded_pixels = ( ( decompression_buffer[ buffer_caret ] & 127 ) + 1 ); + encoded_pixels = ( ( decompression_buffer[ buffer_caret ] & !TGA_RLE_FLAG ) + 1 ); buffer_caret++; + if ((bitmap_caret + (encoded_pixels * pixel_block_size)) >= image_block_size) { + gdFree( decompression_buffer ); + gdFree( conversion_buffer ); + return -1; + } + for (i = 0; i < encoded_pixels; i++) { - for (j = 0; j < pixel_block_size; j++, bitmap_caret++) { - tga->bitmap[ bitmap_caret ] = decompression_buffer[ buffer_caret + j ]; - } + memcpy(tga->bitmap + bitmap_caret, decompression_buffer + buffer_caret, pixel_block_size); + bitmap_caret += pixel_block_size; } buffer_caret += pixel_block_size; + } else { encoded_pixels = decompression_buffer[ buffer_caret ] + 1; buffer_caret++; - for (i = 0; i < encoded_pixels; i++) { - for( j = 0; j < pixel_block_size; j++, bitmap_caret++ ) { - tga->bitmap[ bitmap_caret ] = decompression_buffer[ buffer_caret + j ]; - } - buffer_caret += pixel_block_size; + if ((bitmap_caret + (encoded_pixels * pixel_block_size)) >= image_block_size) { + gdFree( decompression_buffer ); + gdFree( conversion_buffer ); + return -1; } + + memcpy(tga->bitmap + bitmap_caret, decompression_buffer + buffer_caret, encoded_pixels * pixel_block_size); + bitmap_caret += (encoded_pixels * pixel_block_size); + buffer_caret += (encoded_pixels * pixel_block_size); } } debian/patches/CVE-2016-6906-pre2.patch0000644000000000000000000001023313055314402014105 0ustar Backport of: From 4f8e26f2a40ffaa3a5b77be6a49989a1a42e2b83 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Tue, 16 Aug 2016 14:27:23 +0200 Subject: [PATCH] Fix #290: TGA RLE decoding is broken We make it work only, for now. Actually, it doesn't make sense that `oTga::bitmap` is an `int *` as we're storing only bytes there. If this will be changed, we can even get rid of the `conversion_buffer` in `read_image_tga` altogether, and read the image data into the `decompression_buffer` (if RLE'd) or the `tga->bitmap` (if uncompressed) directly. --- src/gd_tga.c | 18 ++++++++++-------- tests/tga/CMakeLists.txt | 1 + tests/tga/Makemodule.am | 8 ++++++-- tests/tga/tga_read.c | 40 ++++++++++++++++++++++++++++++++++++++++ tests/tga/tga_read_rgb.png | Bin 0 -> 2349 bytes tests/tga/tga_read_rgb.tga | Bin 0 -> 90444 bytes tests/tga/tga_read_rgb_rle.tga | Bin 0 -> 9987 bytes 7 files changed, 57 insertions(+), 10 deletions(-) create mode 100644 tests/tga/tga_read.c create mode 100644 tests/tga/tga_read_rgb.png create mode 100644 tests/tga/tga_read_rgb.tga create mode 100644 tests/tga/tga_read_rgb_rle.tga Index: libgd2-2.1.1/src/gd_tga.c =================================================================== --- libgd2-2.1.1.orig/src/gd_tga.c 2017-02-28 10:21:34.452061765 -0500 +++ libgd2-2.1.1/src/gd_tga.c 2017-02-28 10:22:38.160815421 -0500 @@ -191,12 +191,13 @@ { int pixel_block_size = (tga->bits / 8); int image_block_size = (tga->width * tga->height) * pixel_block_size; - uint8_t* decompression_buffer = NULL; + int* decompression_buffer = NULL; unsigned char* conversion_buffer = NULL; int buffer_caret = 0; int bitmap_caret = 0; int i = 0; int encoded_pixels; + int rle_size; if(overflow2(tga->width, tga->height)) { return -1; @@ -260,7 +261,7 @@ * Chunk load the pixel data from an RLE compressed RGB type TGA. */ if (tga->imagetype == TGA_TYPE_RGB_RLE) { - decompression_buffer = (uint8_t*) gdMalloc(image_block_size * sizeof(uint8_t)); + decompression_buffer = (int*) gdMalloc(image_block_size * sizeof(int)); if (decompression_buffer == NULL) { gdFree( decompression_buffer ); return -1; @@ -273,7 +274,8 @@ return -1; } - if (gdGetBuf(conversion_buffer, image_block_size, ctx) != image_block_size) { + rle_size = gdGetBuf(conversion_buffer, image_block_size, ctx); + if (rle_size <= 0) { gdFree(conversion_buffer); gdFree(decompression_buffer); return -1; @@ -281,7 +283,7 @@ buffer_caret = 0; - while( buffer_caret < image_block_size ) { + while( buffer_caret < rle_size) { decompression_buffer[buffer_caret] = (int)conversion_buffer[buffer_caret]; buffer_caret++; } @@ -294,14 +296,14 @@ encoded_pixels = ( ( decompression_buffer[ buffer_caret ] & ~TGA_RLE_FLAG ) + 1 ); buffer_caret++; - if ((bitmap_caret + (encoded_pixels * pixel_block_size)) >= image_block_size) { + if ((bitmap_caret + (encoded_pixels * pixel_block_size)) > image_block_size) { gdFree( decompression_buffer ); gdFree( conversion_buffer ); return -1; } for (i = 0; i < encoded_pixels; i++) { - memcpy(tga->bitmap + bitmap_caret, decompression_buffer + buffer_caret, pixel_block_size); + memcpy(tga->bitmap + bitmap_caret, decompression_buffer + buffer_caret, pixel_block_size * sizeof(int)); bitmap_caret += pixel_block_size; } buffer_caret += pixel_block_size; @@ -310,13 +312,13 @@ encoded_pixels = decompression_buffer[ buffer_caret ] + 1; buffer_caret++; - if ((bitmap_caret + (encoded_pixels * pixel_block_size)) >= image_block_size) { + if ((bitmap_caret + (encoded_pixels * pixel_block_size)) > image_block_size) { gdFree( decompression_buffer ); gdFree( conversion_buffer ); return -1; } - memcpy(tga->bitmap + bitmap_caret, decompression_buffer + buffer_caret, encoded_pixels * pixel_block_size); + memcpy(tga->bitmap + bitmap_caret, decompression_buffer + buffer_caret, encoded_pixels * pixel_block_size * sizeof(int)); bitmap_caret += (encoded_pixels * pixel_block_size); buffer_caret += (encoded_pixels * pixel_block_size); } debian/patches/CVE-2014-2497.patch0000644000000000000000000000162712721574650013261 0ustar 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(+) Index: libgd2-2.1.0/src/gdxpm.c =================================================================== --- libgd2-2.1.0.orig/src/gdxpm.c 2016-05-26 09:27:01.372561275 -0400 +++ libgd2-2.1.0/src/gdxpm.c 2016-05-26 09:27:01.372561275 -0400 @@ -49,6 +49,16 @@ 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) { debian/patches/subdir-objects.patch0000644000000000000000000000064212222240036014550 0ustar --- libgd2.orig/configure.ac +++ libgd2/configure.ac @@ -47,7 +47,7 @@ AC_SUBST(GDLIB_AGE) FEATURES="GD_GIF GD_GIFANIM GD_OPENPOLYGON" AC_SUBST(FEATURES) -AM_INIT_AUTOMAKE([foreign dist-bzip2 dist-xz -Wall -Werror]) +AM_INIT_AUTOMAKE([foreign subdir-objects dist-bzip2 dist-xz -Wall -Werror]) AC_CONFIG_HEADERS([src/config.h:src/config.hin]) dnl newer automake wants this, but we still want to work with older debian/patches/CVE-2016-6912.patch0000644000000000000000000001217313055315157013251 0ustar Backport of: From a49feeae76d41959d85ee733925a4cf40bac61b2 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Tue, 16 Aug 2016 17:40:23 +0200 Subject: [PATCH] Fix double-free in gdImageWebPtr() The issue is that gdImageWebpCtx() (which is called by gdImageWebpPtr() and the other WebP output functions to do the real work) does not return whether it succeeded or failed, so this is not checked in gdImageWebpPtr() and the function wrongly assumes everything is okay, which is not, in this case, because there is a size limitation for WebP, namely that the width and height must by less than 16383. We can't change the signature of gdImageWebpCtx() for API compatibility reasons, so we introduce the static helper _gdImageWebpCtx() which returns success respective failure, so gdImageWebpPtr() and gdImageWebpPtrEx() can check the return value. We leave it solely to libwebp for now to report warnings regarding the failing write. This issue had been reported by Ibrahim El-Sayed to security@libgd.org. CVE-2016-6912 --- src/gd_webp.c | 74 +++++++++++++++++++++++++---------------- tests/webp/.gitignore | 1 + tests/webp/CMakeLists.txt | 1 + tests/webp/Makemodule.am | 6 ++-- tests/webp/bug_double_free.c | 29 ++++++++++++++++ tests/webp/bug_double_free.jpg | Bin 0 -> 576 bytes 6 files changed, 81 insertions(+), 30 deletions(-) create mode 100644 tests/webp/bug_double_free.c create mode 100644 tests/webp/bug_double_free.jpg Index: libgd2-2.1.1/src/gd_webp.c =================================================================== --- libgd2-2.1.1.orig/src/gd_webp.c 2017-02-28 10:41:47.438411038 -0500 +++ libgd2-2.1.1/src/gd_webp.c 2017-02-28 10:42:36.458990937 -0500 @@ -106,41 +106,6 @@ return im; } -BGD_DECLARE(void) gdImageWebpEx (gdImagePtr im, FILE * outFile, int quantization) -{ - gdIOCtx *out = gdNewFileCtx(outFile); - gdImageWebpCtx(im, out, quantization); - out->gd_free(out); -} - -BGD_DECLARE(void) gdImageWebp (gdImagePtr im, FILE * outFile) -{ - gdIOCtx *out = gdNewFileCtx(outFile); - gdImageWebpCtx(im, out, -1); - out->gd_free(out); -} - -BGD_DECLARE(void *) gdImageWebpPtr (gdImagePtr im, int *size) -{ - void *rv; - gdIOCtx *out = gdNewDynamicCtx(2048, NULL); - gdImageWebpCtx(im, out, -1); - rv = gdDPExtractData(out, size); - out->gd_free(out); - - return rv; -} - -BGD_DECLARE(void *) gdImageWebpPtrEx (gdImagePtr im, int *size, int quantization) -{ - void *rv; - gdIOCtx *out = gdNewDynamicCtx(2048, NULL); - gdImageWebpCtx(im, out, quantization); - rv = gdDPExtractData(out, size); - out->gd_free(out); - return rv; -} - /* * Maps normalized QP (quality) to VP8 QP */ @@ -164,7 +129,8 @@ * and in part on demo code from Chapter 15 of "PNG: The Definitive Guide" * (http://www.cdrom.com/pub/png/pngbook.html). */ -BGD_DECLARE(void) gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quantization) +/* returns 0 on success, 1 on failure */ +static int _gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quantization) { int width = im->sx; int height = im->sy; @@ -181,18 +147,18 @@ yuv_height = (height + 1) >> 1; if (overflow2(width, height)) { - return; + return 1; } /* simplification possible, because WebP must not be larger than 16384**2 */ if (overflow2(width * height, 2 * sizeof(unsigned char))) { - return; + return 1; } yuv_nbytes = width * height + 2 * yuv_width * yuv_height; if ((Y = (unsigned char *)gdCalloc(yuv_nbytes, sizeof(unsigned char))) == NULL) { gd_error("gd-webp error: cannot allocate Y buffer"); - return; + return 1; } vp8_quality = mapQualityToVP8QP(quantization); @@ -210,11 +176,73 @@ free(filedata); } gd_error("gd-webp error: WebP Encoder failed"); - return; + return 1; } gdPutBuf (filedata, yuv_nbytes, outfile); free(filedata); + return 0; +} + +/* + Function: gdImageWebpCtx + + Write the image as WebP data via a . See + for more details. + + Parameters: + + im - The image to write. + outfile - The output sink. + quality - Image quality. + + Returns: + + Nothing. +*/ +BGD_DECLARE(void) gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quality) +{ + _gdImageWebpCtx(im, outfile, quality); +} + +BGD_DECLARE(void) gdImageWebpEx (gdImagePtr im, FILE * outFile, int quantization) +{ + gdIOCtx *out = gdNewFileCtx(outFile); + _gdImageWebpCtx(im, out, quantization); + out->gd_free(out); +} + +BGD_DECLARE(void) gdImageWebp (gdImagePtr im, FILE * outFile) +{ + gdIOCtx *out = gdNewFileCtx(outFile); + _gdImageWebpCtx(im, out, -1); + out->gd_free(out); +} + +BGD_DECLARE(void *) gdImageWebpPtr (gdImagePtr im, int *size) +{ + void *rv; + gdIOCtx *out = gdNewDynamicCtx(2048, NULL); + if (_gdImageWebpCtx(im, out, -1)) { + rv = NULL; + } else { + rv = gdDPExtractData(out, size); + } + out->gd_free(out); + + return rv; } +BGD_DECLARE(void *) gdImageWebpPtrEx (gdImagePtr im, int *size, int quantization) +{ + void *rv; + gdIOCtx *out = gdNewDynamicCtx(2048, NULL); + if (_gdImageWebpCtx(im, out, quantization)) { + rv = NULL; + } else { + rv = gdDPExtractData(out, size); + } + out->gd_free(out); + return rv; +} #endif /* HAVE_LIBVPX */ debian/patches/fix-compiled-in-version.patch0000644000000000000000000027342112222240036016307 0ustar --- libgd2.orig/configure.ac +++ libgd2/configure.ac @@ -6,12 +6,12 @@ AC_PREREQ(2.54) # Some m4 magic to have correct version number everywhere m4_define([gd_MAJOR],[2])dnl m4_define([gd_MINOR],[1])dnl -m4_define([gd_REVISION],[0])dnl -dnl m4_define([gd_EXTRA],[rc2]) +m4_define([gd_REVISION],[1])dnl +m4_define([gd_EXTRA],[dev])dnl -m4_ifdef([gd_EXTRA], - [m4_define([gd_PKG_VERSION],[gd_MAJOR.gd_MINOR.gd_REVISION-gd_EXTRA])], - [m4_define([gd_PKG_VERSION],[gd_MAJOR.gd_MINOR.gd_REVISION])] +m4_if(m4_len(gd_EXTRA), 0,dnl + [m4_define([gd_PKG_VERSION],[gd_MAJOR.gd_MINOR.gd_REVISION])],dnl + [m4_define([gd_PKG_VERSION],[gd_MAJOR.gd_MINOR.gd_REVISION-gd_EXTRA])]dnl )dnl AC_INIT([GD], gd_PKG_VERSION, [https://bitbucket.org/libgd/gd-libgd/issues], [libgd], [http://lib.gd]) @@ -25,10 +25,12 @@ GDLIB_MAJOR=gd_MAJOR GDLIB_MINOR=gd_MINOR GDLIB_REVISION=gd_REVISION GDLIB_EXTRA=gd_EXTRA +GDLIB_VERSION=gd_PKG_VERSION AC_SUBST(GDLIB_MAJOR) AC_SUBST(GDLIB_MINOR) AC_SUBST(GDLIB_REVISION) AC_SUBST(GDLIB_EXTRA) +AC_SUBST(GDLIB_VERSION) # Dynamic library version information # See http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info @@ -455,6 +457,7 @@ AC_MSG_RESULT([ AC_CONFIG_FILES([Makefile src/Makefile + src/gd.h tests/Makefile tests/test_config.h config/Makefile --- libgd2.orig/src/gd.h +++ /dev/null @@ -1,1113 +0,0 @@ -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef GD_H -#define GD_H 1 - -#define GD_MAJOR_VERSION 2 -#define GD_MINOR_VERSION 1 -#define GD_RELEASE_VERSION 0 -#define GD_EXTRA_VERSION "alpha" -#define GD_VERSION_STRING "2.1.0-alpha" - -/* Do the DLL dance: dllexport when building the DLL, - dllimport when importing from it, nothing when - not on Silly Silly Windows (tm Aardman Productions). */ - -/* 2.0.20: for headers */ - -/* 2.0.24: __stdcall also needed for Visual BASIC - and other languages. This breaks ABI compatibility - with previous DLL revs, but it's necessary. */ - -/* 2.0.29: WIN32 programmers can declare the NONDLL macro if they - wish to build gd as a static library or by directly including - the gd sources in a project. */ - -/* http://gcc.gnu.org/wiki/Visibility */ -#if defined(_WIN32) || defined(CYGWIN) || defined(_WIN32_WCE) -# ifdef BGDWIN32 -# ifdef NONDLL -# define BGD_EXPORT_DATA_PROT -# else -# ifdef __GNUC__ -# define BGD_EXPORT_DATA_PROT __attribute__ ((dllexport)) -# else -# define BGD_EXPORT_DATA_PROT __declspec(dllexport) -# endif -# endif -# else -# ifdef __GNUC__ -# define BGD_EXPORT_DATA_PROT __attribute__ ((dllimport)) -# else -# define BGD_EXPORT_DATA_PROT __declspec(dllimport) -# endif -# endif -# define BGD_STDCALL __stdcall -# define BGD_EXPORT_DATA_IMPL -#else -# ifdef HAVE_VISIBILITY -# define BGD_EXPORT_DATA_PROT __attribute__ ((visibility ("default"))) -# define BGD_EXPORT_DATA_IMPL __attribute__ ((visibility ("hidden"))) -# else -# define BGD_EXPORT_DATA_PROT -# define BGD_EXPORT_DATA_IMPL -# endif -# define BGD_STDCALL -#endif - -#define BGD_DECLARE(rt) BGD_EXPORT_DATA_PROT rt BGD_STDCALL - -#ifdef __cplusplus - extern "C" - { -#endif - -/* gd.h: declarations file for the graphic-draw module. - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, provided - * that the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation. This software is provided "AS IS." Thomas Boutell and - * Boutell.Com, Inc. disclaim all warranties, either express or implied, - * including but not limited to implied warranties of merchantability and - * fitness for a particular purpose, with respect to this code and accompanying - * documentation. */ - -/* stdio is needed for file I/O. */ -#include -#include -#include "gd_io.h" - -/* The maximum number of palette entries in palette-based images. - In the wonderful new world of gd 2.0, you can of course have - many more colors when using truecolor mode. */ - -#define gdMaxColors 256 - -/* Image type. See functions below; you will not need to change - the elements directly. Use the provided macros to - access sx, sy, the color table, and colorsTotal for - read-only purposes. */ - -/* If 'truecolor' is set true, the image is truecolor; - pixels are represented by integers, which - must be 32 bits wide or more. - - True colors are repsented as follows: - - ARGB - - Where 'A' (alpha channel) occupies only the - LOWER 7 BITS of the MSB. This very small - loss of alpha channel resolution allows gd 2.x - to keep backwards compatibility by allowing - signed integers to be used to represent colors, - and negative numbers to represent special cases, - just as in gd 1.x. */ - -#define gdAlphaMax 127 -#define gdAlphaOpaque 0 -#define gdAlphaTransparent 127 -#define gdRedMax 255 -#define gdGreenMax 255 -#define gdBlueMax 255 -#define gdTrueColorGetAlpha(c) (((c) & 0x7F000000) >> 24) -#define gdTrueColorGetRed(c) (((c) & 0xFF0000) >> 16) -#define gdTrueColorGetGreen(c) (((c) & 0x00FF00) >> 8) -#define gdTrueColorGetBlue(c) ((c) & 0x0000FF) -#define gdEffectReplace 0 -#define gdEffectAlphaBlend 1 -#define gdEffectNormal 2 -#define gdEffectOverlay 3 - -#define GD_TRUE 1 -#define GD_FALSE 0 - -#define GD_EPSILON 1e-6 -#ifndef M_PI -# define M_PI 3.14159265358979323846 -#endif - -/* This function accepts truecolor pixel values only. The - source color is composited with the destination color - based on the alpha channel value of the source color. - The resulting color is opaque. */ - -BGD_DECLARE(int) gdAlphaBlend (int dest, int src); - -enum gdPaletteQuantizationMethod { - GD_QUANT_DEFAULT = 0, - GD_QUANT_JQUANT = 1, /* libjpeg's old median cut. Fast, but only uses 16-bit color. */ - GD_QUANT_NEUQUANT = 2, /* neuquant - approximation using kohonen neural network. */ - GD_QUANT_LIQ = 3 /* combination of algorithms used in libimagequant/pngquant2 aiming for highest quality at cost of speed */ -}; - -/** - * Group: Transform - * - * Constants: gdInterpolationMethod - - * GD_BELL - Bell - * GD_BESSEL - Bessel - * GD_BILINEAR_FIXED - fixed point bilinear - * GD_BICUBIC - Bicubic - * GD_BICUBIC_FIXED - fixed point bicubic integer - * GD_BLACKMAN - Blackman - * GD_BOX - Box - * GD_BSPLINE - BSpline - * GD_CATMULLROM - Catmullrom - * GD_GAUSSIAN - Gaussian - * GD_GENERALIZED_CUBIC - Generalized cubic - * GD_HERMITE - Hermite - * GD_HAMMING - Hamming - * GD_HANNING - Hannig - * GD_MITCHELL - Mitchell - * GD_NEAREST_NEIGHBOUR - Nearest neighbour interpolation - * GD_POWER - Power - * GD_QUADRATIC - Quadratic - * GD_SINC - Sinc - * GD_TRIANGLE - Triangle - * GD_WEIGHTED4 - 4 pixels weighted bilinear interpolation - * - * See also: - * - **/ -typedef enum { - GD_DEFAULT = 0, - GD_BELL, - GD_BESSEL, - GD_BILINEAR_FIXED, - GD_BICUBIC, - GD_BICUBIC_FIXED, - GD_BLACKMAN, - GD_BOX, - GD_BSPLINE, - GD_CATMULLROM, - GD_GAUSSIAN, - GD_GENERALIZED_CUBIC, - GD_HERMITE, - GD_HAMMING, - GD_HANNING, - GD_MITCHELL, - GD_NEAREST_NEIGHBOUR, - GD_POWER, - GD_QUADRATIC, - GD_SINC, - GD_TRIANGLE, - GD_WEIGHTED4, - GD_METHOD_COUNT = 21 -} gdInterpolationMethod; - -/* define struct with name and func ptr and add it to gdImageStruct gdInterpolationMethod interpolation; */ - -/* Interpolation function ptr */ -typedef double (* interpolation_method )(double); - -typedef struct gdImageStruct { - /* Palette-based image pixels */ - unsigned char **pixels; - int sx; - int sy; - /* These are valid in palette images only. See also - 'alpha', which appears later in the structure to - preserve binary backwards compatibility */ - int colorsTotal; - int red[gdMaxColors]; - int green[gdMaxColors]; - int blue[gdMaxColors]; - int open[gdMaxColors]; - /* For backwards compatibility, this is set to the - first palette entry with 100% transparency, - and is also set and reset by the - gdImageColorTransparent function. Newer - applications can allocate palette entries - with any desired level of transparency; however, - bear in mind that many viewers, notably - many web browsers, fail to implement - full alpha channel for PNG and provide - support for full opacity or transparency only. */ - int transparent; - int *polyInts; - int polyAllocated; - struct gdImageStruct *brush; - struct gdImageStruct *tile; - int brushColorMap[gdMaxColors]; - int tileColorMap[gdMaxColors]; - int styleLength; - int stylePos; - int *style; - int interlace; - /* New in 2.0: thickness of line. Initialized to 1. */ - int thick; - /* New in 2.0: alpha channel for palettes. Note that only - Macintosh Internet Explorer and (possibly) Netscape 6 - really support multiple levels of transparency in - palettes, to my knowledge, as of 2/15/01. Most - common browsers will display 100% opaque and - 100% transparent correctly, and do something - unpredictable and/or undesirable for levels - in between. TBB */ - int alpha[gdMaxColors]; - /* Truecolor flag and pixels. New 2.0 fields appear here at the - end to minimize breakage of existing object code. */ - int trueColor; - int **tpixels; - /* Should alpha channel be copied, or applied, each time a - pixel is drawn? This applies to truecolor images only. - No attempt is made to alpha-blend in palette images, - even if semitransparent palette entries exist. - To do that, build your image as a truecolor image, - then quantize down to 8 bits. */ - int alphaBlendingFlag; - /* Should the alpha channel of the image be saved? This affects - PNG at the moment; other future formats may also - have that capability. JPEG doesn't. */ - int saveAlphaFlag; - - /* There should NEVER BE ACCESSOR MACROS FOR ITEMS BELOW HERE, so this - part of the structure can be safely changed in new releases. */ - - /* 2.0.12: anti-aliased globals. 2.0.26: just a few vestiges after - switching to the fast, memory-cheap implementation from PHP-gd. */ - int AA; - int AA_color; - int AA_dont_blend; - - /* 2.0.12: simple clipping rectangle. These values - must be checked for safety when set; please use - gdImageSetClip */ - int cx1; - int cy1; - int cx2; - int cy2; - - /* 2.1.0: allows to specify resolution in dpi */ - unsigned int res_x; - unsigned int res_y; - - /* Selects quantization method, see gdImageTrueColorToPaletteSetMethod() and gdPaletteQuantizationMethod enum. */ - int paletteQuantizationMethod; - /* speed/quality trade-off. 1 = best quality, 10 = best speed. 0 = method-specific default. - Applicable to GD_QUANT_LIQ and GD_QUANT_NEUQUANT. */ - int paletteQuantizationSpeed; - /* Image will remain true-color if conversion to palette cannot achieve given quality. - Value from 1 to 100, 1 = ugly, 100 = perfect. Applicable to GD_QUANT_LIQ.*/ - int paletteQuantizationMinQuality; - /* Image will use minimum number of palette colors needed to achieve given quality. Must be higher than paletteQuantizationMinQuality - Value from 1 to 100, 1 = ugly, 100 = perfect. Applicable to GD_QUANT_LIQ.*/ - int paletteQuantizationMaxQuality; - gdInterpolationMethod interpolation_id; - interpolation_method interpolation; -} -gdImage; - -typedef gdImage *gdImagePtr; - - -/* Point type for use in polygon drawing. */ - -/** - * Group: Types - * - * typedef: gdPointF - * Defines a point in a 2D coordinate system using floating point - * values. - * x - Floating point position (increase from left to right) - * y - Floating point Row position (increase from top to bottom) - * - * typedef: gdPointFPtr - * Pointer to a - * - * See also: - * , , - **/ -typedef struct -{ - double x, y; -} -gdPointF, *gdPointFPtr; - -typedef struct { - /* # of characters in font */ - int nchars; - /* First character is numbered... (usually 32 = space) */ - int offset; - /* Character width and height */ - int w; - int h; - /* Font data; array of characters, one row after another. - Easily included in code, also easily loaded from - data files. */ - char *data; -} -gdFont; - -/* Text functions take these. */ -typedef gdFont *gdFontPtr; - -typedef void(*gdErrorMethod)(int, const char *, va_list); - -BGD_DECLARE(void) gdSetErrorMethod(gdErrorMethod); -BGD_DECLARE(void) gdClearErrorMethod(void); - -/* For backwards compatibility only. Use gdImageSetStyle() - for MUCH more flexible line drawing. Also see - gdImageSetBrush(). */ -#define gdDashSize 4 - -/* Special colors. */ - -#define gdStyled (-2) -#define gdBrushed (-3) -#define gdStyledBrushed (-4) -#define gdTiled (-5) - -/* NOT the same as the transparent color index. - This is used in line styles only. */ -#define gdTransparent (-6) - -#define gdAntiAliased (-7) - -/* Functions to manipulate images. */ - -/* Creates a palette-based image (up to 256 colors). */ -BGD_DECLARE(gdImagePtr) gdImageCreate (int sx, int sy); - -/* An alternate name for the above (2.0). */ -#define gdImageCreatePalette gdImageCreate - -/* Creates a truecolor image (millions of colors). */ -BGD_DECLARE(gdImagePtr) gdImageCreateTrueColor (int sx, int sy); - -/* Creates an image from various file types. These functions - return a palette or truecolor image based on the - nature of the file being loaded. Truecolor PNG - stays truecolor; palette PNG stays palette-based; - JPEG is always truecolor. */ -BGD_DECLARE(gdImagePtr) gdImageCreateFromPng (FILE * fd); -BGD_DECLARE(gdImagePtr) gdImageCreateFromPngCtx (gdIOCtxPtr in); -BGD_DECLARE(gdImagePtr) gdImageCreateFromPngPtr (int size, void *data); - -/* These read the first frame only */ -BGD_DECLARE(gdImagePtr) gdImageCreateFromGif (FILE * fd); -BGD_DECLARE(gdImagePtr) gdImageCreateFromGifCtx (gdIOCtxPtr in); -BGD_DECLARE(gdImagePtr) gdImageCreateFromGifPtr (int size, void *data); -BGD_DECLARE(gdImagePtr) gdImageCreateFromWBMP (FILE * inFile); -BGD_DECLARE(gdImagePtr) gdImageCreateFromWBMPCtx (gdIOCtx * infile); -BGD_DECLARE(gdImagePtr) gdImageCreateFromWBMPPtr (int size, void *data); -BGD_DECLARE(gdImagePtr) gdImageCreateFromJpeg (FILE * infile); -BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegEx (FILE * infile, int ignore_warning); -BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegCtx (gdIOCtx * infile); -BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegCtxEx (gdIOCtx * infile, int ignore_warning); -BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegPtr (int size, void *data); -BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegPtrEx (int size, void *data, int ignore_warning); -BGD_DECLARE(gdImagePtr) gdImageCreateFromWebp (FILE * inFile); -BGD_DECLARE(gdImagePtr) gdImageCreateFromWebpPtr (int size, void *data); -BGD_DECLARE(gdImagePtr) gdImageCreateFromWebpCtx (gdIOCtx * infile); - -BGD_DECLARE(gdImagePtr) gdImageCreateFromTiff(FILE *inFile); -BGD_DECLARE(gdImagePtr) gdImageCreateFromTiffCtx(gdIOCtx *infile); -BGD_DECLARE(gdImagePtr) gdImageCreateFromTiffPtr(int size, void *data); - -BGD_DECLARE(gdImagePtr) gdImageCreateFromTga( FILE * fp ); -BGD_DECLARE(gdImagePtr) gdImageCreateFromTgaCtx(gdIOCtx* ctx); -BGD_DECLARE(gdImagePtr) gdImageCreateFromTgaPtr(int size, void *data); - -BGD_DECLARE(gdImagePtr) gdImageCreateFromBmp (FILE * inFile); -BGD_DECLARE(gdImagePtr) gdImageCreateFromBmpPtr (int size, void *data); -BGD_DECLARE(gdImagePtr) gdImageCreateFromBmpCtx (gdIOCtxPtr infile); - -/* A custom data source. */ -/* The source function must return -1 on error, otherwise the number - of bytes fetched. 0 is EOF, not an error! */ -/* context will be passed to your source function. */ - -typedef struct { - int (*source) (void *context, char *buffer, int len); - void *context; -} -gdSource, *gdSourcePtr; - -/* Deprecated in favor of gdImageCreateFromPngCtx */ -BGD_DECLARE(gdImagePtr) gdImageCreateFromPngSource (gdSourcePtr in); - -BGD_DECLARE(gdImagePtr) gdImageCreateFromGd (FILE * in); -BGD_DECLARE(gdImagePtr) gdImageCreateFromGdCtx (gdIOCtxPtr in); -BGD_DECLARE(gdImagePtr) gdImageCreateFromGdPtr (int size, void *data); - -BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2 (FILE * in); -BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ctx (gdIOCtxPtr in); -BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ptr (int size, void *data); - -BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Part (FILE * in, int srcx, int srcy, int w, - int h); -BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2PartCtx (gdIOCtxPtr in, int srcx, int srcy, - int w, int h); -BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2PartPtr (int size, void *data, int srcx, int srcy, - int w, int h); -/* 2.0.10: prototype was missing */ -BGD_DECLARE(gdImagePtr) gdImageCreateFromXbm (FILE * in); -BGD_DECLARE(void) gdImageXbmCtx(gdImagePtr image, char* file_name, int fg, gdIOCtx * out); - -/* NOTE: filename, not FILE */ -BGD_DECLARE(gdImagePtr) gdImageCreateFromXpm (char *filename); - -BGD_DECLARE(void) gdImageDestroy (gdImagePtr im); - -/* Replaces or blends with the background depending on the - most recent call to gdImageAlphaBlending and the - alpha channel value of 'color'; default is to overwrite. - Tiling and line styling are also implemented - here. All other gd drawing functions pass through this call, - allowing for many useful effects. */ - -BGD_DECLARE(void) gdImageSetPixel (gdImagePtr im, int x, int y, int color); -/* FreeType 2 text output with hook to extra flags */ - -BGD_DECLARE(int) gdImageGetPixel (gdImagePtr im, int x, int y); -BGD_DECLARE(int) gdImageGetTrueColorPixel (gdImagePtr im, int x, int y); - -BGD_DECLARE(void) gdImageAABlend (gdImagePtr im); - -BGD_DECLARE(void) gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color); - -/* For backwards compatibility only. Use gdImageSetStyle() - for much more flexible line drawing. */ -BGD_DECLARE(void) gdImageDashedLine (gdImagePtr im, int x1, int y1, int x2, int y2, - int color); -/* Corners specified (not width and height). Upper left first, lower right - second. */ -BGD_DECLARE(void) gdImageRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, - int color); -/* Solid bar. Upper left corner first, lower right corner second. */ -BGD_DECLARE(void) gdImageFilledRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, - int color); -BGD_DECLARE(void) gdImageSetClip(gdImagePtr im, int x1, int y1, int x2, int y2); -BGD_DECLARE(void) gdImageGetClip(gdImagePtr im, int *x1P, int *y1P, int *x2P, int *y2P); -BGD_DECLARE(void) gdImageSetResolution(gdImagePtr im, const unsigned int res_x, const unsigned int res_y); -BGD_DECLARE(int) gdImageBoundsSafe (gdImagePtr im, int x, int y); -BGD_DECLARE(void) gdImageChar (gdImagePtr im, gdFontPtr f, int x, int y, int c, - int color); -BGD_DECLARE(void) gdImageCharUp (gdImagePtr im, gdFontPtr f, int x, int y, int c, - int color); -BGD_DECLARE(void) gdImageString (gdImagePtr im, gdFontPtr f, int x, int y, - unsigned char *s, int color); -BGD_DECLARE(void) gdImageStringUp (gdImagePtr im, gdFontPtr f, int x, int y, - unsigned char *s, int color); -BGD_DECLARE(void) gdImageString16 (gdImagePtr im, gdFontPtr f, int x, int y, - unsigned short *s, int color); -BGD_DECLARE(void) gdImageStringUp16 (gdImagePtr im, gdFontPtr f, int x, int y, - unsigned short *s, int color); - -/* 2.0.16: for thread-safe use of gdImageStringFT and friends, - call this before allowing any thread to call gdImageStringFT. - Otherwise it is invoked by the first thread to invoke - gdImageStringFT, with a very small but real risk of a race condition. - Return 0 on success, nonzero on failure to initialize freetype. */ -BGD_DECLARE(int) gdFontCacheSetup (void); - -/* Optional: clean up after application is done using fonts in - gdImageStringFT(). */ -BGD_DECLARE(void) gdFontCacheShutdown (void); -/* 2.0.20: for backwards compatibility. A few applications did start calling - this function when it first appeared although it was never documented. - Simply invokes gdFontCacheShutdown. */ -BGD_DECLARE(void) gdFreeFontCache (void); - -/* Calls gdImageStringFT. Provided for backwards compatibility only. */ -BGD_DECLARE(char *) gdImageStringTTF (gdImage * im, int *brect, int fg, char *fontlist, - double ptsize, double angle, int x, int y, - char *string); - -/* FreeType 2 text output */ -BGD_DECLARE(char *) gdImageStringFT (gdImage * im, int *brect, int fg, char *fontlist, - double ptsize, double angle, int x, int y, - char *string); - -/* 2.0.5: provides an extensible way to pass additional parameters. - Thanks to Wez Furlong, sorry for the delay. */ - -typedef struct { - int flags; /* Logical OR of gdFTEX_ values */ - double linespacing; /* fine tune line spacing for '\n' */ - int charmap; /* TBB: 2.0.12: may be gdFTEX_Unicode, - gdFTEX_Shift_JIS, gdFTEX_Big5, - or gdFTEX_Adobe_Custom; - when not specified, maps are searched - for in the above order. */ - int hdpi; /* if (flags & gdFTEX_RESOLUTION) */ - int vdpi; /* if (flags & gdFTEX_RESOLUTION) */ - char *xshow; /* if (flags & gdFTEX_XSHOW) - then, on return, xshow is a malloc'ed - string containing xshow position data for - the last string. - - NB. The caller is responsible for gdFree'ing - the xshow string. - */ - char *fontpath; /* if (flags & gdFTEX_RETURNFONTPATHNAME) - then, on return, fontpath is a malloc'ed - string containing the actual font file path name - used, which can be interesting when fontconfig - is in use. - - The caller is responsible for gdFree'ing the - fontpath string. - */ - -} -gdFTStringExtra, *gdFTStringExtraPtr; - -#define gdFTEX_LINESPACE 1 -#define gdFTEX_CHARMAP 2 -#define gdFTEX_RESOLUTION 4 -#define gdFTEX_DISABLE_KERNING 8 -#define gdFTEX_XSHOW 16 -/* The default unless gdFTUseFontConfig(1); has been called: - fontlist is a full or partial font file pathname or list thereof - (i.e. just like before 2.0.29) */ -#define gdFTEX_FONTPATHNAME 32 -/* Necessary to use fontconfig patterns instead of font pathnames - as the fontlist argument, unless gdFTUseFontConfig(1); has - been called. New in 2.0.29 */ -#define gdFTEX_FONTCONFIG 64 -/* Sometimes interesting when fontconfig is used: the fontpath - element of the structure above will contain a gdMalloc'd string - copy of the actual font file pathname used, if this flag is set - when the call is made */ -#define gdFTEX_RETURNFONTPATHNAME 128 - -/* If flag is nonzero, the fontlist parameter to gdImageStringFT - and gdImageStringFTEx shall be assumed to be a fontconfig font pattern - if fontconfig was compiled into gd. This function returns zero - if fontconfig is not available, nonzero otherwise. */ -BGD_DECLARE(int) gdFTUseFontConfig(int flag); - -/* These are NOT flags; set one in 'charmap' if you set the - gdFTEX_CHARMAP bit in 'flags'. */ -#define gdFTEX_Unicode 0 -#define gdFTEX_Shift_JIS 1 -#define gdFTEX_Big5 2 -#define gdFTEX_Adobe_Custom 3 - -BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, - double ptsize, double angle, int x, int y, - char *string, gdFTStringExtraPtr strex); - -/* Point type for use in polygon drawing. */ -typedef struct { - int x, y; -} -gdPoint, *gdPointPtr; - -typedef struct { - int x, y; - int width, height; -} -gdRect, *gdRectPtr; - - -BGD_DECLARE(void) gdImagePolygon (gdImagePtr im, gdPointPtr p, int n, int c); -BGD_DECLARE(void) gdImageOpenPolygon (gdImagePtr im, gdPointPtr p, int n, int c); -BGD_DECLARE(void) gdImageFilledPolygon (gdImagePtr im, gdPointPtr p, int n, int c); - -/* These functions still work with truecolor images, - for which they never return error. */ -BGD_DECLARE(int) gdImageColorAllocate (gdImagePtr im, int r, int g, int b); -/* gd 2.0: palette entries with non-opaque transparency are permitted. */ -BGD_DECLARE(int) gdImageColorAllocateAlpha (gdImagePtr im, int r, int g, int b, int a); -/* Assumes opaque is the preferred alpha channel value */ -BGD_DECLARE(int) gdImageColorClosest (gdImagePtr im, int r, int g, int b); -/* Closest match taking all four parameters into account. - A slightly different color with the same transparency - beats the exact same color with radically different - transparency */ -BGD_DECLARE(int) gdImageColorClosestAlpha (gdImagePtr im, int r, int g, int b, int a); -/* An alternate method */ -BGD_DECLARE(int) gdImageColorClosestHWB (gdImagePtr im, int r, int g, int b); -/* Returns exact, 100% opaque matches only */ -BGD_DECLARE(int) gdImageColorExact (gdImagePtr im, int r, int g, int b); -/* Returns an exact match only, including alpha */ -BGD_DECLARE(int) gdImageColorExactAlpha (gdImagePtr im, int r, int g, int b, int a); -/* Opaque only */ -BGD_DECLARE(int) gdImageColorResolve (gdImagePtr im, int r, int g, int b); -/* Based on gdImageColorExactAlpha and gdImageColorClosestAlpha */ -BGD_DECLARE(int) gdImageColorResolveAlpha (gdImagePtr im, int r, int g, int b, int a); - -/* A simpler way to obtain an opaque truecolor value for drawing on a - truecolor image. Not for use with palette images! */ - -#define gdTrueColor(r, g, b) (((r) << 16) + \ - ((g) << 8) + \ - (b)) - -/* Returns a truecolor value with an alpha channel component. - gdAlphaMax (127, **NOT 255**) is transparent, 0 is completely - opaque. */ - -#define gdTrueColorAlpha(r, g, b, a) (((a) << 24) + \ - ((r) << 16) + \ - ((g) << 8) + \ - (b)) - -BGD_DECLARE(void) gdImageColorDeallocate (gdImagePtr im, int color); - -/* Converts a truecolor image to a palette-based image, - using a high-quality two-pass quantization routine - which attempts to preserve alpha channel information - as well as R/G/B color information when creating - a palette. If ditherFlag is set, the image will be - dithered to approximate colors better, at the expense - of some obvious "speckling." colorsWanted can be - anything up to 256. If the original source image - includes photographic information or anything that - came out of a JPEG, 256 is strongly recommended. - - Better yet, don't use these function -- write real - truecolor PNGs and JPEGs. The disk space gain of - conversion to palette is not great (for small images - it can be negative) and the quality loss is ugly. - - DIFFERENCES: gdImageCreatePaletteFromTrueColor creates and - returns a new image. gdImageTrueColorToPalette modifies - an existing image, and the truecolor pixels are discarded. - - gdImageTrueColorToPalette() returns TRUE on success, FALSE on failure. -*/ - -BGD_DECLARE(gdImagePtr) gdImageCreatePaletteFromTrueColor (gdImagePtr im, int ditherFlag, - int colorsWanted); - -BGD_DECLARE(int) gdImageTrueColorToPalette (gdImagePtr im, int ditherFlag, - int colorsWanted); - -BGD_DECLARE(int) gdImagePaletteToTrueColor(gdImagePtr src); - -/* An attempt at getting the results of gdImageTrueColorToPalette to - * look a bit more like the original (im1 is the original and im2 is - * the palette version */ - -BGD_DECLARE(int) gdImageColorMatch(gdImagePtr im1, gdImagePtr im2); - -/* Selects quantization method used for subsequent gdImageTrueColorToPalette calls. - See gdPaletteQuantizationMethod enum (e.g. GD_QUANT_NEUQUANT, GD_QUANT_LIQ). - Speed is from 1 (highest quality) to 10 (fastest). - Speed 0 selects method-specific default (recommended). - - Returns FALSE if the given method is invalid or not available. -*/ -BGD_DECLARE(int) gdImageTrueColorToPaletteSetMethod (gdImagePtr im, int method, int speed); - -/* - Chooses quality range that subsequent call to gdImageTrueColorToPalette will aim for. - Min and max quality is in range 1-100 (1 = ugly, 100 = perfect). Max must be higher than min. - If palette cannot represent image with at least min_quality, then image will remain true-color. - If palette can represent image with quality better than max_quality, then lower number of colors will be used. - This function has effect only when GD_QUANT_LIQ method has been selected and the source image is true-color. -*/ -BGD_DECLARE(void) gdImageTrueColorToPaletteSetQuality (gdImagePtr im, int min_quality, int max_quality); - -/* Specifies a color index (if a palette image) or an - RGB color (if a truecolor image) which should be - considered 100% transparent. FOR TRUECOLOR IMAGES, - THIS IS IGNORED IF AN ALPHA CHANNEL IS BEING - SAVED. Use gdImageSaveAlpha(im, 0); to - turn off the saving of a full alpha channel in - a truecolor image. Note that gdImageColorTransparent - is usually compatible with older browsers that - do not understand full alpha channels well. TBB */ -BGD_DECLARE(void) gdImageColorTransparent (gdImagePtr im, int color); - -BGD_DECLARE(void) gdImagePaletteCopy (gdImagePtr dst, gdImagePtr src); - -typedef int (*gdCallbackImageColor)(gdImagePtr im, int src); - -BGD_DECLARE(int) gdImageColorReplace(gdImagePtr im, int src, int dst); -BGD_DECLARE(int) gdImageColorReplaceThreshold(gdImagePtr im, int src, int dst, float threshold); -BGD_DECLARE(int) gdImageColorReplaceArray(gdImagePtr im, int len, int *src, int *dst); -BGD_DECLARE(int) gdImageColorReplaceCallback(gdImagePtr im, gdCallbackImageColor callback); - -BGD_DECLARE(void) gdImageGif (gdImagePtr im, FILE * out); -BGD_DECLARE(void) gdImagePng (gdImagePtr im, FILE * out); -BGD_DECLARE(void) gdImagePngCtx (gdImagePtr im, gdIOCtx * out); -BGD_DECLARE(void) gdImageGifCtx (gdImagePtr im, gdIOCtx * out); -BGD_DECLARE(void) gdImageTiff(gdImagePtr im, FILE *outFile); -BGD_DECLARE(void *) gdImageTiffPtr(gdImagePtr im, int *size); -BGD_DECLARE(void) gdImageTiffCtx(gdImagePtr image, gdIOCtx *out); - -BGD_DECLARE(void *) gdImageBmpPtr(gdImagePtr im, int *size, int compression); -BGD_DECLARE(void) gdImageBmp(gdImagePtr im, FILE *outFile, int compression); -BGD_DECLARE(void) gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression); - -/* 2.0.12: Compression level: 0-9 or -1, where 0 is NO COMPRESSION at all, - 1 is FASTEST but produces larger files, 9 provides the best - compression (smallest files) but takes a long time to compress, and - -1 selects the default compiled into the zlib library. */ -BGD_DECLARE(void) gdImagePngEx (gdImagePtr im, FILE * out, int level); -BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * out, int level); - -BGD_DECLARE(void) gdImageWBMP (gdImagePtr image, int fg, FILE * out); -BGD_DECLARE(void) gdImageWBMPCtx (gdImagePtr image, int fg, gdIOCtx * out); - -/* Guaranteed to correctly free memory returned by the gdImage*Ptr - functions */ -BGD_DECLARE(void) gdFree (void *m); - -/* Best to free this memory with gdFree(), not free() */ -BGD_DECLARE(void *) gdImageWBMPPtr (gdImagePtr im, int *size, int fg); - -/* 100 is highest quality (there is always a little loss with JPEG). - 0 is lowest. 10 is about the lowest useful setting. */ -BGD_DECLARE(void) gdImageJpeg (gdImagePtr im, FILE * out, int quality); -BGD_DECLARE(void) gdImageJpegCtx (gdImagePtr im, gdIOCtx * out, int quality); - -/* Best to free this memory with gdFree(), not free() */ -BGD_DECLARE(void *) gdImageJpegPtr (gdImagePtr im, int *size, int quality); - -BGD_DECLARE(void) gdImageWebpEx (gdImagePtr im, FILE * outFile, int quantization); -BGD_DECLARE(void) gdImageWebp (gdImagePtr im, FILE * outFile); -BGD_DECLARE(void *) gdImageWebpPtr (gdImagePtr im, int *size); -BGD_DECLARE(void *) gdImageWebpPtrEx (gdImagePtr im, int *size, int quantization); -BGD_DECLARE(void) gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quantization); - -/* Legal values for Disposal. gdDisposalNone is always used by - the built-in optimizer if previm is passed. */ - -enum { - gdDisposalUnknown, - gdDisposalNone, - gdDisposalRestoreBackground, - gdDisposalRestorePrevious -}; - -BGD_DECLARE(void) gdImageGifAnimBegin(gdImagePtr im, FILE *outFile, int GlobalCM, int Loops); -BGD_DECLARE(void) gdImageGifAnimAdd(gdImagePtr im, FILE *outFile, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm); -BGD_DECLARE(void) gdImageGifAnimEnd(FILE *outFile); -BGD_DECLARE(void) gdImageGifAnimBeginCtx(gdImagePtr im, gdIOCtx *out, int GlobalCM, int Loops); -BGD_DECLARE(void) gdImageGifAnimAddCtx(gdImagePtr im, gdIOCtx *out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm); -BGD_DECLARE(void) gdImageGifAnimEndCtx(gdIOCtx *out); -BGD_DECLARE(void *) gdImageGifAnimBeginPtr(gdImagePtr im, int *size, int GlobalCM, int Loops); -BGD_DECLARE(void *) gdImageGifAnimAddPtr(gdImagePtr im, int *size, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm); -BGD_DECLARE(void *) gdImageGifAnimEndPtr(int *size); - -/* A custom data sink. For backwards compatibility. Use gdIOCtx - instead. The sink function must return -1 on error, otherwise the - number of bytes written, which must be equal to len. Context will - be passed to your sink function. -*/ -typedef struct { - int (*sink) (void *context, const char *buffer, int len); - void *context; -} -gdSink, *gdSinkPtr; - -BGD_DECLARE(void) gdImagePngToSink (gdImagePtr im, gdSinkPtr out); - -BGD_DECLARE(void) gdImageGd (gdImagePtr im, FILE * out); -BGD_DECLARE(void) gdImageGd2 (gdImagePtr im, FILE * out, int cs, int fmt); - -/* Best to free this memory with gdFree(), not free() */ -BGD_DECLARE(void *) gdImageGifPtr (gdImagePtr im, int *size); - -/* Best to free this memory with gdFree(), not free() */ -BGD_DECLARE(void *) gdImagePngPtr (gdImagePtr im, int *size); -BGD_DECLARE(void *) gdImagePngPtrEx (gdImagePtr im, int *size, int level); - -/* Best to free this memory with gdFree(), not free() */ -BGD_DECLARE(void *) gdImageGdPtr (gdImagePtr im, int *size); - -/* Best to free this memory with gdFree(), not free() */ -BGD_DECLARE(void *) gdImageGd2Ptr (gdImagePtr im, int cs, int fmt, int *size); - -/* Style is a bitwise OR ( | operator ) of these. - gdArc and gdChord are mutually exclusive; - gdChord just connects the starting and ending - angles with a straight line, while gdArc produces - a rounded edge. gdPie is a synonym for gdArc. - gdNoFill indicates that the arc or chord should be - outlined, not filled. gdEdged, used together with - gdNoFill, indicates that the beginning and ending - angles should be connected to the center; this is - a good way to outline (rather than fill) a - 'pie slice'. */ -#define gdArc 0 -#define gdPie gdArc -#define gdChord 1 -#define gdNoFill 2 -#define gdEdged 4 - -BGD_DECLARE(void) gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, - int e, int color, int style); -BGD_DECLARE(void) gdImageArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e, - int color); -BGD_DECLARE(void) gdImageEllipse(gdImagePtr im, int cx, int cy, int w, int h, int color); -BGD_DECLARE(void) gdImageFilledEllipse (gdImagePtr im, int cx, int cy, int w, int h, - int color); -BGD_DECLARE(void) gdImageFillToBorder (gdImagePtr im, int x, int y, int border, - int color); -BGD_DECLARE(void) gdImageFill (gdImagePtr im, int x, int y, int color); -BGD_DECLARE(void) gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, - int srcX, int srcY, int w, int h); -BGD_DECLARE(void) gdImageCopyMerge (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, - int srcX, int srcY, int w, int h, int pct); -BGD_DECLARE(void) gdImageCopyMergeGray (gdImagePtr dst, gdImagePtr src, int dstX, - int dstY, int srcX, int srcY, int w, int h, - int pct); - -/* Stretches or shrinks to fit, as needed. Does NOT attempt - to average the entire set of source pixels that scale down onto the - destination pixel. */ -BGD_DECLARE(void) gdImageCopyResized (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, - int srcX, int srcY, int dstW, int dstH, int srcW, - int srcH); - -/* gd 2.0: stretches or shrinks to fit, as needed. When called with a - truecolor destination image, this function averages the - entire set of source pixels that scale down onto the - destination pixel, taking into account what portion of the - destination pixel each source pixel represents. This is a - floating point operation, but this is not a performance issue - on modern hardware, except for some embedded devices. If the - destination is a palette image, gdImageCopyResized is - substituted automatically. */ -BGD_DECLARE(void) gdImageCopyResampled (gdImagePtr dst, gdImagePtr src, int dstX, - int dstY, int srcX, int srcY, int dstW, int dstH, - int srcW, int srcH); - -/* gd 2.0.8: gdImageCopyRotated is added. Source - is a rectangle, with its upper left corner at - srcX and srcY. Destination is the *center* of - the rotated copy. Angle is in degrees, same as - gdImageArc. Floating point destination center - coordinates allow accurate rotation of - objects of odd-numbered width or height. */ -BGD_DECLARE(void) gdImageCopyRotated (gdImagePtr dst, - gdImagePtr src, - double dstX, double dstY, - int srcX, int srcY, - int srcWidth, int srcHeight, int angle); - -BGD_DECLARE(gdImagePtr) gdImageClone (gdImagePtr src); - -BGD_DECLARE(void) gdImageSetBrush (gdImagePtr im, gdImagePtr brush); -BGD_DECLARE(void) gdImageSetTile (gdImagePtr im, gdImagePtr tile); -BGD_DECLARE(void) gdImageSetAntiAliased (gdImagePtr im, int c); -BGD_DECLARE(void) gdImageSetAntiAliasedDontBlend (gdImagePtr im, int c, int dont_blend); -BGD_DECLARE(void) gdImageSetStyle (gdImagePtr im, int *style, int noOfPixels); -/* Line thickness (defaults to 1). Affects lines, ellipses, - rectangles, polygons and so forth. */ -BGD_DECLARE(void) gdImageSetThickness (gdImagePtr im, int thickness); -/* On or off (1 or 0) for all three of these. */ -BGD_DECLARE(void) gdImageInterlace (gdImagePtr im, int interlaceArg); -BGD_DECLARE(void) gdImageAlphaBlending (gdImagePtr im, int alphaBlendingArg); -BGD_DECLARE(void) gdImageSaveAlpha (gdImagePtr im, int saveAlphaArg); - -BGD_DECLARE(gdImagePtr) gdImageNeuQuant(gdImagePtr im, const int max_color, int sample_factor); - -enum gdPixelateMode { - GD_PIXELATE_UPPERLEFT, - GD_PIXELATE_AVERAGE -}; - -BGD_DECLARE(int) gdImagePixelate(gdImagePtr im, int block_size, const unsigned int mode); - -typedef struct { - int sub; - int plus; - unsigned int num_colors; - int *colors; - unsigned int seed; -} gdScatter, *gdScatterPtr; - -BGD_DECLARE(int) gdImageScatter(gdImagePtr im, int sub, int plus); -BGD_DECLARE(int) gdImageScatterColor(gdImagePtr im, int sub, int plus, int colors[], unsigned int num_colors); -BGD_DECLARE(int) gdImageScatterEx(gdImagePtr im, gdScatterPtr s); -BGD_DECLARE(int) gdImageSmooth(gdImagePtr im, float weight); -BGD_DECLARE(int) gdImageMeanRemoval(gdImagePtr im); -BGD_DECLARE(int) gdImageEmboss(gdImagePtr im); -BGD_DECLARE(int) gdImageGaussianBlur(gdImagePtr im); -BGD_DECLARE(int) gdImageEdgeDetectQuick(gdImagePtr src); -BGD_DECLARE(int) gdImageSelectiveBlur( gdImagePtr src); -BGD_DECLARE(int) gdImageConvolution(gdImagePtr src, float filter[3][3], float filter_div, float offset); -BGD_DECLARE(int) gdImageColor(gdImagePtr src, const int red, const int green, const int blue, const int alpha); -BGD_DECLARE(int) gdImageContrast(gdImagePtr src, double contrast); -BGD_DECLARE(int) gdImageBrightness(gdImagePtr src, int brightness); -BGD_DECLARE(int) gdImageGrayScale(gdImagePtr src); -BGD_DECLARE(int) gdImageNegate(gdImagePtr src); - -/* Macros to access information about images. */ - -/* Returns nonzero if the image is a truecolor image, - zero for a palette image. */ -#define gdImageTrueColor(im) ((im)->trueColor) - -#define gdImageSX(im) ((im)->sx) -#define gdImageSY(im) ((im)->sy) -#define gdImageColorsTotal(im) ((im)->colorsTotal) -#define gdImageRed(im, c) ((im)->trueColor ? gdTrueColorGetRed(c) : \ - (im)->red[(c)]) -#define gdImageGreen(im, c) ((im)->trueColor ? gdTrueColorGetGreen(c) : \ - (im)->green[(c)]) -#define gdImageBlue(im, c) ((im)->trueColor ? gdTrueColorGetBlue(c) : \ - (im)->blue[(c)]) -#define gdImageAlpha(im, c) ((im)->trueColor ? gdTrueColorGetAlpha(c) : \ - (im)->alpha[(c)]) -#define gdImageGetTransparent(im) ((im)->transparent) -#define gdImageGetInterlaced(im) ((im)->interlace) - -/* These macros provide direct access to pixels in - palette-based and truecolor images, respectively. - If you use these macros, you must perform your own - bounds checking. Use of the macro for the correct type - of image is also your responsibility. */ -#define gdImagePalettePixel(im, x, y) (im)->pixels[(y)][(x)] -#define gdImageTrueColorPixel(im, x, y) (im)->tpixels[(y)][(x)] - -#define gdImageResolutionX(im) (im)->res_x -#define gdImageResolutionY(im) (im)->res_y - -/* I/O Support routines. */ - -BGD_DECLARE(gdIOCtx *) gdNewFileCtx (FILE *); -/* If data is null, size is ignored and an initial data buffer is - allocated automatically. NOTE: this function assumes gd has the right - to free or reallocate "data" at will! Also note that gd will free - "data" when the IO context is freed. If data is not null, it must point - to memory allocated with gdMalloc, or by a call to gdImage[something]Ptr. - If not, see gdNewDynamicCtxEx for an alternative. */ -BGD_DECLARE(gdIOCtx *) gdNewDynamicCtx (int size, void *data); -/* 2.0.21: if freeFlag is nonzero, gd will free and/or reallocate "data" as - needed as described above. If freeFlag is zero, gd will never free - or reallocate "data", which means that the context should only be used - for *reading* an image from a memory buffer, or writing an image to a - memory buffer which is already large enough. If the memory buffer is - not large enough and an image write is attempted, the write operation - will fail. Those wishing to write an image to a buffer in memory have - a much simpler alternative in the gdImage[something]Ptr functions. */ -BGD_DECLARE(gdIOCtx *) gdNewDynamicCtxEx (int size, void *data, int freeFlag); -BGD_DECLARE(gdIOCtx *) gdNewSSCtx (gdSourcePtr in, gdSinkPtr out); -BGD_DECLARE(void *) gdDPExtractData (struct gdIOCtx *ctx, int *size); - -#define GD2_CHUNKSIZE 128 -#define GD2_CHUNKSIZE_MIN 64 -#define GD2_CHUNKSIZE_MAX 4096 - -#define GD2_VERS 2 -#define GD2_ID "gd2" - -#define GD2_FMT_RAW 1 -#define GD2_FMT_COMPRESSED 2 - -/* Image comparison definitions */ -BGD_DECLARE(int) gdImageCompare (gdImagePtr im1, gdImagePtr im2); - -BGD_DECLARE(void) gdImageFlipHorizontal(gdImagePtr im); -BGD_DECLARE(void) gdImageFlipVertical(gdImagePtr im); -BGD_DECLARE(void) gdImageFlipBoth(gdImagePtr im); - -#define GD_FLIP_HORINZONTAL 1 -#define GD_FLIP_VERTICAL 2 -#define GD_FLIP_BOTH 3 - -/** - * Group: Crop - * - * Constants: gdCropMode - * GD_CROP_DEFAULT - Default crop mode (4 corners or background) - * GD_CROP_TRANSPARENT - Crop using the transparent color - * GD_CROP_BLACK - Crop black borders - * GD_CROP_WHITE - Crop white borders - * GD_CROP_SIDES - Crop using colors of the 4 corners - * - * See also: - * - **/ -enum gdCropMode { - GD_CROP_DEFAULT = 0, - GD_CROP_TRANSPARENT, - GD_CROP_BLACK, - GD_CROP_WHITE, - GD_CROP_SIDES, - GD_CROP_THRESHOLD -}; - -BGD_DECLARE(gdImagePtr) gdImageCrop(gdImagePtr src, const gdRect *crop); -BGD_DECLARE(gdImagePtr) gdImageCropAuto(gdImagePtr im, const unsigned int mode); -BGD_DECLARE(gdImagePtr) gdImageCropThreshold(gdImagePtr im, const unsigned int color, const float threshold); - -BGD_DECLARE(int) gdImageSetInterpolationMethod(gdImagePtr im, gdInterpolationMethod id); - -gdImagePtr gdImageScaleBilinear(gdImagePtr im, const unsigned int new_width, const unsigned int new_height); -gdImagePtr gdImageScaleBicubic(gdImagePtr src_img, const unsigned int new_width, const unsigned int new_height); -gdImagePtr gdImageScaleBicubicFixed(gdImagePtr src, const unsigned int width, const unsigned int height); -gdImagePtr gdImageScaleNearestNeighbour(gdImagePtr im, const unsigned int width, const unsigned int height); -gdImagePtr gdImageScaleTwoPass(const gdImagePtr pOrigImage, const unsigned int uOrigWidth, const unsigned int uOrigHeight, const unsigned int uNewWidth, const unsigned int uNewHeight); -BGD_DECLARE(gdImagePtr) gdImageScale(const gdImagePtr src, const unsigned int new_width, const unsigned int new_height); - -gdImagePtr gdImageRotate90(gdImagePtr src, int ignoretransparent); -gdImagePtr gdImageRotate180(gdImagePtr src, int ignoretransparent); -gdImagePtr gdImageRotate270(gdImagePtr src, int ignoretransparent); -gdImagePtr gdImageRotateNearestNeighbour(gdImagePtr src, const float degrees, const int bgColor); -gdImagePtr gdImageRotateBilinear(gdImagePtr src, const float degrees, const int bgColor); -gdImagePtr gdImageRotateBicubicFixed(gdImagePtr src, const float degrees, const int bgColor); -gdImagePtr gdImageRotateGeneric(gdImagePtr src, const float degrees, const int bgColor); -BGD_DECLARE(gdImagePtr) gdImageRotateInterpolated(const gdImagePtr src, const float angle, int bgcolor); - -typedef enum { - GD_AFFINE_TRANSLATE = 0, - GD_AFFINE_SCALE, - GD_AFFINE_ROTATE, - GD_AFFINE_SHEAR_HORIZONTAL, - GD_AFFINE_SHEAR_VERTICAL -} gdAffineStandardMatrix; - -BGD_DECLARE(int) gdAffineApplyToPointF (gdPointFPtr dst, const gdPointFPtr src, const double affine[6]); -BGD_DECLARE(int) gdAffineInvert (double dst[6], const double src[6]); -BGD_DECLARE(int) gdAffineFlip (double dst_affine[6], const double src_affine[6], const int flip_h, const int flip_v); -BGD_DECLARE(int) gdAffineConcat (double dst[6], const double m1[6], const double m2[6]); - -BGD_DECLARE(int) gdAffineIdentity (double dst[6]); -BGD_DECLARE(int) gdAffineScale (double dst[6], const double scale_x, const double scale_y); -BGD_DECLARE(int) gdAffineRotate (double dst[6], const double angle); -BGD_DECLARE(int) gdAffineShearHorizontal (double dst[6], const double angle); -BGD_DECLARE(int) gdAffineShearVertical(double dst[6], const double angle); -BGD_DECLARE(int) gdAffineTranslate (double dst[6], const double offset_x, const double offset_y); -BGD_DECLARE(double) gdAffineExpansion (const double src[6]); -BGD_DECLARE(int) gdAffineRectilinear (const double src[6]); -BGD_DECLARE(int) gdAffineEqual (const double matrix1[6], const double matrix2[6]); -BGD_DECLARE(int) gdTransformAffineGetImage(gdImagePtr *dst, const gdImagePtr src, gdRectPtr src_area, const double affine[6]); -BGD_DECLARE(int) gdTransformAffineCopy(gdImagePtr dst, int dst_x, int dst_y, const gdImagePtr src, gdRectPtr src_region, const double affine[6]); -/* -gdTransformAffineCopy(gdImagePtr dst, int x0, int y0, int x1, int y1, - const gdImagePtr src, int src_width, int src_height, - const double affine[6]); -*/ -BGD_DECLARE(int) gdTransformAffineBoundingBox(gdRectPtr src, const double affine[6], gdRectPtr bbox); - -#define GD_CMP_IMAGE 1 /* Actual image IS different */ -#define GD_CMP_NUM_COLORS 2 /* Number of Colours in pallette differ */ -#define GD_CMP_COLOR 4 /* Image colours differ */ -#define GD_CMP_SIZE_X 8 /* Image width differs */ -#define GD_CMP_SIZE_Y 16 /* Image heights differ */ -#define GD_CMP_TRANSPARENT 32 /* Transparent colour */ -#define GD_CMP_BACKGROUND 64 /* Background colour */ -#define GD_CMP_INTERLACE 128 /* Interlaced setting */ -#define GD_CMP_TRUECOLOR 256 /* Truecolor vs palette differs */ - -/* resolution affects ttf font rendering, particularly hinting */ -#define GD_RESOLUTION 96 /* pixels per inch */ - -#ifdef __cplusplus -} -#endif - -/* newfangled special effects */ -#include "gdfx.h" - -#endif /* GD_H */ - -#ifdef __cplusplus -} -#endif --- /dev/null +++ libgd2/src/gd.h.in @@ -0,0 +1,1113 @@ +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef GD_H +#define GD_H 1 + +#define GD_MAJOR_VERSION @GDLIB_MAJOR@ +#define GD_MINOR_VERSION @GDLIB_MINOR@ +#define GD_RELEASE_VERSION @GDLIB_REVISION@ +#define GD_EXTRA_VERSION "@GDLIB_EXTRA@" +#define GD_VERSION_STRING "@GDLIB_VERSION@" + +/* Do the DLL dance: dllexport when building the DLL, + dllimport when importing from it, nothing when + not on Silly Silly Windows (tm Aardman Productions). */ + +/* 2.0.20: for headers */ + +/* 2.0.24: __stdcall also needed for Visual BASIC + and other languages. This breaks ABI compatibility + with previous DLL revs, but it's necessary. */ + +/* 2.0.29: WIN32 programmers can declare the NONDLL macro if they + wish to build gd as a static library or by directly including + the gd sources in a project. */ + +/* http://gcc.gnu.org/wiki/Visibility */ +#if defined(_WIN32) || defined(CYGWIN) || defined(_WIN32_WCE) +# ifdef BGDWIN32 +# ifdef NONDLL +# define BGD_EXPORT_DATA_PROT +# else +# ifdef __GNUC__ +# define BGD_EXPORT_DATA_PROT __attribute__ ((dllexport)) +# else +# define BGD_EXPORT_DATA_PROT __declspec(dllexport) +# endif +# endif +# else +# ifdef __GNUC__ +# define BGD_EXPORT_DATA_PROT __attribute__ ((dllimport)) +# else +# define BGD_EXPORT_DATA_PROT __declspec(dllimport) +# endif +# endif +# define BGD_STDCALL __stdcall +# define BGD_EXPORT_DATA_IMPL +#else +# ifdef HAVE_VISIBILITY +# define BGD_EXPORT_DATA_PROT __attribute__ ((visibility ("default"))) +# define BGD_EXPORT_DATA_IMPL __attribute__ ((visibility ("hidden"))) +# else +# define BGD_EXPORT_DATA_PROT +# define BGD_EXPORT_DATA_IMPL +# endif +# define BGD_STDCALL +#endif + +#define BGD_DECLARE(rt) BGD_EXPORT_DATA_PROT rt BGD_STDCALL + +#ifdef __cplusplus + extern "C" + { +#endif + +/* gd.h: declarations file for the graphic-draw module. + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation. This software is provided "AS IS." Thomas Boutell and + * Boutell.Com, Inc. disclaim all warranties, either express or implied, + * including but not limited to implied warranties of merchantability and + * fitness for a particular purpose, with respect to this code and accompanying + * documentation. */ + +/* stdio is needed for file I/O. */ +#include +#include +#include "gd_io.h" + +/* The maximum number of palette entries in palette-based images. + In the wonderful new world of gd 2.0, you can of course have + many more colors when using truecolor mode. */ + +#define gdMaxColors 256 + +/* Image type. See functions below; you will not need to change + the elements directly. Use the provided macros to + access sx, sy, the color table, and colorsTotal for + read-only purposes. */ + +/* If 'truecolor' is set true, the image is truecolor; + pixels are represented by integers, which + must be 32 bits wide or more. + + True colors are repsented as follows: + + ARGB + + Where 'A' (alpha channel) occupies only the + LOWER 7 BITS of the MSB. This very small + loss of alpha channel resolution allows gd 2.x + to keep backwards compatibility by allowing + signed integers to be used to represent colors, + and negative numbers to represent special cases, + just as in gd 1.x. */ + +#define gdAlphaMax 127 +#define gdAlphaOpaque 0 +#define gdAlphaTransparent 127 +#define gdRedMax 255 +#define gdGreenMax 255 +#define gdBlueMax 255 +#define gdTrueColorGetAlpha(c) (((c) & 0x7F000000) >> 24) +#define gdTrueColorGetRed(c) (((c) & 0xFF0000) >> 16) +#define gdTrueColorGetGreen(c) (((c) & 0x00FF00) >> 8) +#define gdTrueColorGetBlue(c) ((c) & 0x0000FF) +#define gdEffectReplace 0 +#define gdEffectAlphaBlend 1 +#define gdEffectNormal 2 +#define gdEffectOverlay 3 + +#define GD_TRUE 1 +#define GD_FALSE 0 + +#define GD_EPSILON 1e-6 +#ifndef M_PI +# define M_PI 3.14159265358979323846 +#endif + +/* This function accepts truecolor pixel values only. The + source color is composited with the destination color + based on the alpha channel value of the source color. + The resulting color is opaque. */ + +BGD_DECLARE(int) gdAlphaBlend (int dest, int src); + +enum gdPaletteQuantizationMethod { + GD_QUANT_DEFAULT = 0, + GD_QUANT_JQUANT = 1, /* libjpeg's old median cut. Fast, but only uses 16-bit color. */ + GD_QUANT_NEUQUANT = 2, /* neuquant - approximation using kohonen neural network. */ + GD_QUANT_LIQ = 3 /* combination of algorithms used in libimagequant/pngquant2 aiming for highest quality at cost of speed */ +}; + +/** + * Group: Transform + * + * Constants: gdInterpolationMethod + + * GD_BELL - Bell + * GD_BESSEL - Bessel + * GD_BILINEAR_FIXED - fixed point bilinear + * GD_BICUBIC - Bicubic + * GD_BICUBIC_FIXED - fixed point bicubic integer + * GD_BLACKMAN - Blackman + * GD_BOX - Box + * GD_BSPLINE - BSpline + * GD_CATMULLROM - Catmullrom + * GD_GAUSSIAN - Gaussian + * GD_GENERALIZED_CUBIC - Generalized cubic + * GD_HERMITE - Hermite + * GD_HAMMING - Hamming + * GD_HANNING - Hannig + * GD_MITCHELL - Mitchell + * GD_NEAREST_NEIGHBOUR - Nearest neighbour interpolation + * GD_POWER - Power + * GD_QUADRATIC - Quadratic + * GD_SINC - Sinc + * GD_TRIANGLE - Triangle + * GD_WEIGHTED4 - 4 pixels weighted bilinear interpolation + * + * See also: + * + **/ +typedef enum { + GD_DEFAULT = 0, + GD_BELL, + GD_BESSEL, + GD_BILINEAR_FIXED, + GD_BICUBIC, + GD_BICUBIC_FIXED, + GD_BLACKMAN, + GD_BOX, + GD_BSPLINE, + GD_CATMULLROM, + GD_GAUSSIAN, + GD_GENERALIZED_CUBIC, + GD_HERMITE, + GD_HAMMING, + GD_HANNING, + GD_MITCHELL, + GD_NEAREST_NEIGHBOUR, + GD_POWER, + GD_QUADRATIC, + GD_SINC, + GD_TRIANGLE, + GD_WEIGHTED4, + GD_METHOD_COUNT = 21 +} gdInterpolationMethod; + +/* define struct with name and func ptr and add it to gdImageStruct gdInterpolationMethod interpolation; */ + +/* Interpolation function ptr */ +typedef double (* interpolation_method )(double); + +typedef struct gdImageStruct { + /* Palette-based image pixels */ + unsigned char **pixels; + int sx; + int sy; + /* These are valid in palette images only. See also + 'alpha', which appears later in the structure to + preserve binary backwards compatibility */ + int colorsTotal; + int red[gdMaxColors]; + int green[gdMaxColors]; + int blue[gdMaxColors]; + int open[gdMaxColors]; + /* For backwards compatibility, this is set to the + first palette entry with 100% transparency, + and is also set and reset by the + gdImageColorTransparent function. Newer + applications can allocate palette entries + with any desired level of transparency; however, + bear in mind that many viewers, notably + many web browsers, fail to implement + full alpha channel for PNG and provide + support for full opacity or transparency only. */ + int transparent; + int *polyInts; + int polyAllocated; + struct gdImageStruct *brush; + struct gdImageStruct *tile; + int brushColorMap[gdMaxColors]; + int tileColorMap[gdMaxColors]; + int styleLength; + int stylePos; + int *style; + int interlace; + /* New in 2.0: thickness of line. Initialized to 1. */ + int thick; + /* New in 2.0: alpha channel for palettes. Note that only + Macintosh Internet Explorer and (possibly) Netscape 6 + really support multiple levels of transparency in + palettes, to my knowledge, as of 2/15/01. Most + common browsers will display 100% opaque and + 100% transparent correctly, and do something + unpredictable and/or undesirable for levels + in between. TBB */ + int alpha[gdMaxColors]; + /* Truecolor flag and pixels. New 2.0 fields appear here at the + end to minimize breakage of existing object code. */ + int trueColor; + int **tpixels; + /* Should alpha channel be copied, or applied, each time a + pixel is drawn? This applies to truecolor images only. + No attempt is made to alpha-blend in palette images, + even if semitransparent palette entries exist. + To do that, build your image as a truecolor image, + then quantize down to 8 bits. */ + int alphaBlendingFlag; + /* Should the alpha channel of the image be saved? This affects + PNG at the moment; other future formats may also + have that capability. JPEG doesn't. */ + int saveAlphaFlag; + + /* There should NEVER BE ACCESSOR MACROS FOR ITEMS BELOW HERE, so this + part of the structure can be safely changed in new releases. */ + + /* 2.0.12: anti-aliased globals. 2.0.26: just a few vestiges after + switching to the fast, memory-cheap implementation from PHP-gd. */ + int AA; + int AA_color; + int AA_dont_blend; + + /* 2.0.12: simple clipping rectangle. These values + must be checked for safety when set; please use + gdImageSetClip */ + int cx1; + int cy1; + int cx2; + int cy2; + + /* 2.1.0: allows to specify resolution in dpi */ + unsigned int res_x; + unsigned int res_y; + + /* Selects quantization method, see gdImageTrueColorToPaletteSetMethod() and gdPaletteQuantizationMethod enum. */ + int paletteQuantizationMethod; + /* speed/quality trade-off. 1 = best quality, 10 = best speed. 0 = method-specific default. + Applicable to GD_QUANT_LIQ and GD_QUANT_NEUQUANT. */ + int paletteQuantizationSpeed; + /* Image will remain true-color if conversion to palette cannot achieve given quality. + Value from 1 to 100, 1 = ugly, 100 = perfect. Applicable to GD_QUANT_LIQ.*/ + int paletteQuantizationMinQuality; + /* Image will use minimum number of palette colors needed to achieve given quality. Must be higher than paletteQuantizationMinQuality + Value from 1 to 100, 1 = ugly, 100 = perfect. Applicable to GD_QUANT_LIQ.*/ + int paletteQuantizationMaxQuality; + gdInterpolationMethod interpolation_id; + interpolation_method interpolation; +} +gdImage; + +typedef gdImage *gdImagePtr; + + +/* Point type for use in polygon drawing. */ + +/** + * Group: Types + * + * typedef: gdPointF + * Defines a point in a 2D coordinate system using floating point + * values. + * x - Floating point position (increase from left to right) + * y - Floating point Row position (increase from top to bottom) + * + * typedef: gdPointFPtr + * Pointer to a + * + * See also: + * , , + **/ +typedef struct +{ + double x, y; +} +gdPointF, *gdPointFPtr; + +typedef struct { + /* # of characters in font */ + int nchars; + /* First character is numbered... (usually 32 = space) */ + int offset; + /* Character width and height */ + int w; + int h; + /* Font data; array of characters, one row after another. + Easily included in code, also easily loaded from + data files. */ + char *data; +} +gdFont; + +/* Text functions take these. */ +typedef gdFont *gdFontPtr; + +typedef void(*gdErrorMethod)(int, const char *, va_list); + +BGD_DECLARE(void) gdSetErrorMethod(gdErrorMethod); +BGD_DECLARE(void) gdClearErrorMethod(void); + +/* For backwards compatibility only. Use gdImageSetStyle() + for MUCH more flexible line drawing. Also see + gdImageSetBrush(). */ +#define gdDashSize 4 + +/* Special colors. */ + +#define gdStyled (-2) +#define gdBrushed (-3) +#define gdStyledBrushed (-4) +#define gdTiled (-5) + +/* NOT the same as the transparent color index. + This is used in line styles only. */ +#define gdTransparent (-6) + +#define gdAntiAliased (-7) + +/* Functions to manipulate images. */ + +/* Creates a palette-based image (up to 256 colors). */ +BGD_DECLARE(gdImagePtr) gdImageCreate (int sx, int sy); + +/* An alternate name for the above (2.0). */ +#define gdImageCreatePalette gdImageCreate + +/* Creates a truecolor image (millions of colors). */ +BGD_DECLARE(gdImagePtr) gdImageCreateTrueColor (int sx, int sy); + +/* Creates an image from various file types. These functions + return a palette or truecolor image based on the + nature of the file being loaded. Truecolor PNG + stays truecolor; palette PNG stays palette-based; + JPEG is always truecolor. */ +BGD_DECLARE(gdImagePtr) gdImageCreateFromPng (FILE * fd); +BGD_DECLARE(gdImagePtr) gdImageCreateFromPngCtx (gdIOCtxPtr in); +BGD_DECLARE(gdImagePtr) gdImageCreateFromPngPtr (int size, void *data); + +/* These read the first frame only */ +BGD_DECLARE(gdImagePtr) gdImageCreateFromGif (FILE * fd); +BGD_DECLARE(gdImagePtr) gdImageCreateFromGifCtx (gdIOCtxPtr in); +BGD_DECLARE(gdImagePtr) gdImageCreateFromGifPtr (int size, void *data); +BGD_DECLARE(gdImagePtr) gdImageCreateFromWBMP (FILE * inFile); +BGD_DECLARE(gdImagePtr) gdImageCreateFromWBMPCtx (gdIOCtx * infile); +BGD_DECLARE(gdImagePtr) gdImageCreateFromWBMPPtr (int size, void *data); +BGD_DECLARE(gdImagePtr) gdImageCreateFromJpeg (FILE * infile); +BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegEx (FILE * infile, int ignore_warning); +BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegCtx (gdIOCtx * infile); +BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegCtxEx (gdIOCtx * infile, int ignore_warning); +BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegPtr (int size, void *data); +BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegPtrEx (int size, void *data, int ignore_warning); +BGD_DECLARE(gdImagePtr) gdImageCreateFromWebp (FILE * inFile); +BGD_DECLARE(gdImagePtr) gdImageCreateFromWebpPtr (int size, void *data); +BGD_DECLARE(gdImagePtr) gdImageCreateFromWebpCtx (gdIOCtx * infile); + +BGD_DECLARE(gdImagePtr) gdImageCreateFromTiff(FILE *inFile); +BGD_DECLARE(gdImagePtr) gdImageCreateFromTiffCtx(gdIOCtx *infile); +BGD_DECLARE(gdImagePtr) gdImageCreateFromTiffPtr(int size, void *data); + +BGD_DECLARE(gdImagePtr) gdImageCreateFromTga( FILE * fp ); +BGD_DECLARE(gdImagePtr) gdImageCreateFromTgaCtx(gdIOCtx* ctx); +BGD_DECLARE(gdImagePtr) gdImageCreateFromTgaPtr(int size, void *data); + +BGD_DECLARE(gdImagePtr) gdImageCreateFromBmp (FILE * inFile); +BGD_DECLARE(gdImagePtr) gdImageCreateFromBmpPtr (int size, void *data); +BGD_DECLARE(gdImagePtr) gdImageCreateFromBmpCtx (gdIOCtxPtr infile); + +/* A custom data source. */ +/* The source function must return -1 on error, otherwise the number + of bytes fetched. 0 is EOF, not an error! */ +/* context will be passed to your source function. */ + +typedef struct { + int (*source) (void *context, char *buffer, int len); + void *context; +} +gdSource, *gdSourcePtr; + +/* Deprecated in favor of gdImageCreateFromPngCtx */ +BGD_DECLARE(gdImagePtr) gdImageCreateFromPngSource (gdSourcePtr in); + +BGD_DECLARE(gdImagePtr) gdImageCreateFromGd (FILE * in); +BGD_DECLARE(gdImagePtr) gdImageCreateFromGdCtx (gdIOCtxPtr in); +BGD_DECLARE(gdImagePtr) gdImageCreateFromGdPtr (int size, void *data); + +BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2 (FILE * in); +BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ctx (gdIOCtxPtr in); +BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ptr (int size, void *data); + +BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Part (FILE * in, int srcx, int srcy, int w, + int h); +BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2PartCtx (gdIOCtxPtr in, int srcx, int srcy, + int w, int h); +BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2PartPtr (int size, void *data, int srcx, int srcy, + int w, int h); +/* 2.0.10: prototype was missing */ +BGD_DECLARE(gdImagePtr) gdImageCreateFromXbm (FILE * in); +BGD_DECLARE(void) gdImageXbmCtx(gdImagePtr image, char* file_name, int fg, gdIOCtx * out); + +/* NOTE: filename, not FILE */ +BGD_DECLARE(gdImagePtr) gdImageCreateFromXpm (char *filename); + +BGD_DECLARE(void) gdImageDestroy (gdImagePtr im); + +/* Replaces or blends with the background depending on the + most recent call to gdImageAlphaBlending and the + alpha channel value of 'color'; default is to overwrite. + Tiling and line styling are also implemented + here. All other gd drawing functions pass through this call, + allowing for many useful effects. */ + +BGD_DECLARE(void) gdImageSetPixel (gdImagePtr im, int x, int y, int color); +/* FreeType 2 text output with hook to extra flags */ + +BGD_DECLARE(int) gdImageGetPixel (gdImagePtr im, int x, int y); +BGD_DECLARE(int) gdImageGetTrueColorPixel (gdImagePtr im, int x, int y); + +BGD_DECLARE(void) gdImageAABlend (gdImagePtr im); + +BGD_DECLARE(void) gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color); + +/* For backwards compatibility only. Use gdImageSetStyle() + for much more flexible line drawing. */ +BGD_DECLARE(void) gdImageDashedLine (gdImagePtr im, int x1, int y1, int x2, int y2, + int color); +/* Corners specified (not width and height). Upper left first, lower right + second. */ +BGD_DECLARE(void) gdImageRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, + int color); +/* Solid bar. Upper left corner first, lower right corner second. */ +BGD_DECLARE(void) gdImageFilledRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, + int color); +BGD_DECLARE(void) gdImageSetClip(gdImagePtr im, int x1, int y1, int x2, int y2); +BGD_DECLARE(void) gdImageGetClip(gdImagePtr im, int *x1P, int *y1P, int *x2P, int *y2P); +BGD_DECLARE(void) gdImageSetResolution(gdImagePtr im, const unsigned int res_x, const unsigned int res_y); +BGD_DECLARE(int) gdImageBoundsSafe (gdImagePtr im, int x, int y); +BGD_DECLARE(void) gdImageChar (gdImagePtr im, gdFontPtr f, int x, int y, int c, + int color); +BGD_DECLARE(void) gdImageCharUp (gdImagePtr im, gdFontPtr f, int x, int y, int c, + int color); +BGD_DECLARE(void) gdImageString (gdImagePtr im, gdFontPtr f, int x, int y, + unsigned char *s, int color); +BGD_DECLARE(void) gdImageStringUp (gdImagePtr im, gdFontPtr f, int x, int y, + unsigned char *s, int color); +BGD_DECLARE(void) gdImageString16 (gdImagePtr im, gdFontPtr f, int x, int y, + unsigned short *s, int color); +BGD_DECLARE(void) gdImageStringUp16 (gdImagePtr im, gdFontPtr f, int x, int y, + unsigned short *s, int color); + +/* 2.0.16: for thread-safe use of gdImageStringFT and friends, + call this before allowing any thread to call gdImageStringFT. + Otherwise it is invoked by the first thread to invoke + gdImageStringFT, with a very small but real risk of a race condition. + Return 0 on success, nonzero on failure to initialize freetype. */ +BGD_DECLARE(int) gdFontCacheSetup (void); + +/* Optional: clean up after application is done using fonts in + gdImageStringFT(). */ +BGD_DECLARE(void) gdFontCacheShutdown (void); +/* 2.0.20: for backwards compatibility. A few applications did start calling + this function when it first appeared although it was never documented. + Simply invokes gdFontCacheShutdown. */ +BGD_DECLARE(void) gdFreeFontCache (void); + +/* Calls gdImageStringFT. Provided for backwards compatibility only. */ +BGD_DECLARE(char *) gdImageStringTTF (gdImage * im, int *brect, int fg, char *fontlist, + double ptsize, double angle, int x, int y, + char *string); + +/* FreeType 2 text output */ +BGD_DECLARE(char *) gdImageStringFT (gdImage * im, int *brect, int fg, char *fontlist, + double ptsize, double angle, int x, int y, + char *string); + +/* 2.0.5: provides an extensible way to pass additional parameters. + Thanks to Wez Furlong, sorry for the delay. */ + +typedef struct { + int flags; /* Logical OR of gdFTEX_ values */ + double linespacing; /* fine tune line spacing for '\n' */ + int charmap; /* TBB: 2.0.12: may be gdFTEX_Unicode, + gdFTEX_Shift_JIS, gdFTEX_Big5, + or gdFTEX_Adobe_Custom; + when not specified, maps are searched + for in the above order. */ + int hdpi; /* if (flags & gdFTEX_RESOLUTION) */ + int vdpi; /* if (flags & gdFTEX_RESOLUTION) */ + char *xshow; /* if (flags & gdFTEX_XSHOW) + then, on return, xshow is a malloc'ed + string containing xshow position data for + the last string. + + NB. The caller is responsible for gdFree'ing + the xshow string. + */ + char *fontpath; /* if (flags & gdFTEX_RETURNFONTPATHNAME) + then, on return, fontpath is a malloc'ed + string containing the actual font file path name + used, which can be interesting when fontconfig + is in use. + + The caller is responsible for gdFree'ing the + fontpath string. + */ + +} +gdFTStringExtra, *gdFTStringExtraPtr; + +#define gdFTEX_LINESPACE 1 +#define gdFTEX_CHARMAP 2 +#define gdFTEX_RESOLUTION 4 +#define gdFTEX_DISABLE_KERNING 8 +#define gdFTEX_XSHOW 16 +/* The default unless gdFTUseFontConfig(1); has been called: + fontlist is a full or partial font file pathname or list thereof + (i.e. just like before 2.0.29) */ +#define gdFTEX_FONTPATHNAME 32 +/* Necessary to use fontconfig patterns instead of font pathnames + as the fontlist argument, unless gdFTUseFontConfig(1); has + been called. New in 2.0.29 */ +#define gdFTEX_FONTCONFIG 64 +/* Sometimes interesting when fontconfig is used: the fontpath + element of the structure above will contain a gdMalloc'd string + copy of the actual font file pathname used, if this flag is set + when the call is made */ +#define gdFTEX_RETURNFONTPATHNAME 128 + +/* If flag is nonzero, the fontlist parameter to gdImageStringFT + and gdImageStringFTEx shall be assumed to be a fontconfig font pattern + if fontconfig was compiled into gd. This function returns zero + if fontconfig is not available, nonzero otherwise. */ +BGD_DECLARE(int) gdFTUseFontConfig(int flag); + +/* These are NOT flags; set one in 'charmap' if you set the + gdFTEX_CHARMAP bit in 'flags'. */ +#define gdFTEX_Unicode 0 +#define gdFTEX_Shift_JIS 1 +#define gdFTEX_Big5 2 +#define gdFTEX_Adobe_Custom 3 + +BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, + double ptsize, double angle, int x, int y, + char *string, gdFTStringExtraPtr strex); + +/* Point type for use in polygon drawing. */ +typedef struct { + int x, y; +} +gdPoint, *gdPointPtr; + +typedef struct { + int x, y; + int width, height; +} +gdRect, *gdRectPtr; + + +BGD_DECLARE(void) gdImagePolygon (gdImagePtr im, gdPointPtr p, int n, int c); +BGD_DECLARE(void) gdImageOpenPolygon (gdImagePtr im, gdPointPtr p, int n, int c); +BGD_DECLARE(void) gdImageFilledPolygon (gdImagePtr im, gdPointPtr p, int n, int c); + +/* These functions still work with truecolor images, + for which they never return error. */ +BGD_DECLARE(int) gdImageColorAllocate (gdImagePtr im, int r, int g, int b); +/* gd 2.0: palette entries with non-opaque transparency are permitted. */ +BGD_DECLARE(int) gdImageColorAllocateAlpha (gdImagePtr im, int r, int g, int b, int a); +/* Assumes opaque is the preferred alpha channel value */ +BGD_DECLARE(int) gdImageColorClosest (gdImagePtr im, int r, int g, int b); +/* Closest match taking all four parameters into account. + A slightly different color with the same transparency + beats the exact same color with radically different + transparency */ +BGD_DECLARE(int) gdImageColorClosestAlpha (gdImagePtr im, int r, int g, int b, int a); +/* An alternate method */ +BGD_DECLARE(int) gdImageColorClosestHWB (gdImagePtr im, int r, int g, int b); +/* Returns exact, 100% opaque matches only */ +BGD_DECLARE(int) gdImageColorExact (gdImagePtr im, int r, int g, int b); +/* Returns an exact match only, including alpha */ +BGD_DECLARE(int) gdImageColorExactAlpha (gdImagePtr im, int r, int g, int b, int a); +/* Opaque only */ +BGD_DECLARE(int) gdImageColorResolve (gdImagePtr im, int r, int g, int b); +/* Based on gdImageColorExactAlpha and gdImageColorClosestAlpha */ +BGD_DECLARE(int) gdImageColorResolveAlpha (gdImagePtr im, int r, int g, int b, int a); + +/* A simpler way to obtain an opaque truecolor value for drawing on a + truecolor image. Not for use with palette images! */ + +#define gdTrueColor(r, g, b) (((r) << 16) + \ + ((g) << 8) + \ + (b)) + +/* Returns a truecolor value with an alpha channel component. + gdAlphaMax (127, **NOT 255**) is transparent, 0 is completely + opaque. */ + +#define gdTrueColorAlpha(r, g, b, a) (((a) << 24) + \ + ((r) << 16) + \ + ((g) << 8) + \ + (b)) + +BGD_DECLARE(void) gdImageColorDeallocate (gdImagePtr im, int color); + +/* Converts a truecolor image to a palette-based image, + using a high-quality two-pass quantization routine + which attempts to preserve alpha channel information + as well as R/G/B color information when creating + a palette. If ditherFlag is set, the image will be + dithered to approximate colors better, at the expense + of some obvious "speckling." colorsWanted can be + anything up to 256. If the original source image + includes photographic information or anything that + came out of a JPEG, 256 is strongly recommended. + + Better yet, don't use these function -- write real + truecolor PNGs and JPEGs. The disk space gain of + conversion to palette is not great (for small images + it can be negative) and the quality loss is ugly. + + DIFFERENCES: gdImageCreatePaletteFromTrueColor creates and + returns a new image. gdImageTrueColorToPalette modifies + an existing image, and the truecolor pixels are discarded. + + gdImageTrueColorToPalette() returns TRUE on success, FALSE on failure. +*/ + +BGD_DECLARE(gdImagePtr) gdImageCreatePaletteFromTrueColor (gdImagePtr im, int ditherFlag, + int colorsWanted); + +BGD_DECLARE(int) gdImageTrueColorToPalette (gdImagePtr im, int ditherFlag, + int colorsWanted); + +BGD_DECLARE(int) gdImagePaletteToTrueColor(gdImagePtr src); + +/* An attempt at getting the results of gdImageTrueColorToPalette to + * look a bit more like the original (im1 is the original and im2 is + * the palette version */ + +BGD_DECLARE(int) gdImageColorMatch(gdImagePtr im1, gdImagePtr im2); + +/* Selects quantization method used for subsequent gdImageTrueColorToPalette calls. + See gdPaletteQuantizationMethod enum (e.g. GD_QUANT_NEUQUANT, GD_QUANT_LIQ). + Speed is from 1 (highest quality) to 10 (fastest). + Speed 0 selects method-specific default (recommended). + + Returns FALSE if the given method is invalid or not available. +*/ +BGD_DECLARE(int) gdImageTrueColorToPaletteSetMethod (gdImagePtr im, int method, int speed); + +/* + Chooses quality range that subsequent call to gdImageTrueColorToPalette will aim for. + Min and max quality is in range 1-100 (1 = ugly, 100 = perfect). Max must be higher than min. + If palette cannot represent image with at least min_quality, then image will remain true-color. + If palette can represent image with quality better than max_quality, then lower number of colors will be used. + This function has effect only when GD_QUANT_LIQ method has been selected and the source image is true-color. +*/ +BGD_DECLARE(void) gdImageTrueColorToPaletteSetQuality (gdImagePtr im, int min_quality, int max_quality); + +/* Specifies a color index (if a palette image) or an + RGB color (if a truecolor image) which should be + considered 100% transparent. FOR TRUECOLOR IMAGES, + THIS IS IGNORED IF AN ALPHA CHANNEL IS BEING + SAVED. Use gdImageSaveAlpha(im, 0); to + turn off the saving of a full alpha channel in + a truecolor image. Note that gdImageColorTransparent + is usually compatible with older browsers that + do not understand full alpha channels well. TBB */ +BGD_DECLARE(void) gdImageColorTransparent (gdImagePtr im, int color); + +BGD_DECLARE(void) gdImagePaletteCopy (gdImagePtr dst, gdImagePtr src); + +typedef int (*gdCallbackImageColor)(gdImagePtr im, int src); + +BGD_DECLARE(int) gdImageColorReplace(gdImagePtr im, int src, int dst); +BGD_DECLARE(int) gdImageColorReplaceThreshold(gdImagePtr im, int src, int dst, float threshold); +BGD_DECLARE(int) gdImageColorReplaceArray(gdImagePtr im, int len, int *src, int *dst); +BGD_DECLARE(int) gdImageColorReplaceCallback(gdImagePtr im, gdCallbackImageColor callback); + +BGD_DECLARE(void) gdImageGif (gdImagePtr im, FILE * out); +BGD_DECLARE(void) gdImagePng (gdImagePtr im, FILE * out); +BGD_DECLARE(void) gdImagePngCtx (gdImagePtr im, gdIOCtx * out); +BGD_DECLARE(void) gdImageGifCtx (gdImagePtr im, gdIOCtx * out); +BGD_DECLARE(void) gdImageTiff(gdImagePtr im, FILE *outFile); +BGD_DECLARE(void *) gdImageTiffPtr(gdImagePtr im, int *size); +BGD_DECLARE(void) gdImageTiffCtx(gdImagePtr image, gdIOCtx *out); + +BGD_DECLARE(void *) gdImageBmpPtr(gdImagePtr im, int *size, int compression); +BGD_DECLARE(void) gdImageBmp(gdImagePtr im, FILE *outFile, int compression); +BGD_DECLARE(void) gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression); + +/* 2.0.12: Compression level: 0-9 or -1, where 0 is NO COMPRESSION at all, + 1 is FASTEST but produces larger files, 9 provides the best + compression (smallest files) but takes a long time to compress, and + -1 selects the default compiled into the zlib library. */ +BGD_DECLARE(void) gdImagePngEx (gdImagePtr im, FILE * out, int level); +BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * out, int level); + +BGD_DECLARE(void) gdImageWBMP (gdImagePtr image, int fg, FILE * out); +BGD_DECLARE(void) gdImageWBMPCtx (gdImagePtr image, int fg, gdIOCtx * out); + +/* Guaranteed to correctly free memory returned by the gdImage*Ptr + functions */ +BGD_DECLARE(void) gdFree (void *m); + +/* Best to free this memory with gdFree(), not free() */ +BGD_DECLARE(void *) gdImageWBMPPtr (gdImagePtr im, int *size, int fg); + +/* 100 is highest quality (there is always a little loss with JPEG). + 0 is lowest. 10 is about the lowest useful setting. */ +BGD_DECLARE(void) gdImageJpeg (gdImagePtr im, FILE * out, int quality); +BGD_DECLARE(void) gdImageJpegCtx (gdImagePtr im, gdIOCtx * out, int quality); + +/* Best to free this memory with gdFree(), not free() */ +BGD_DECLARE(void *) gdImageJpegPtr (gdImagePtr im, int *size, int quality); + +BGD_DECLARE(void) gdImageWebpEx (gdImagePtr im, FILE * outFile, int quantization); +BGD_DECLARE(void) gdImageWebp (gdImagePtr im, FILE * outFile); +BGD_DECLARE(void *) gdImageWebpPtr (gdImagePtr im, int *size); +BGD_DECLARE(void *) gdImageWebpPtrEx (gdImagePtr im, int *size, int quantization); +BGD_DECLARE(void) gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quantization); + +/* Legal values for Disposal. gdDisposalNone is always used by + the built-in optimizer if previm is passed. */ + +enum { + gdDisposalUnknown, + gdDisposalNone, + gdDisposalRestoreBackground, + gdDisposalRestorePrevious +}; + +BGD_DECLARE(void) gdImageGifAnimBegin(gdImagePtr im, FILE *outFile, int GlobalCM, int Loops); +BGD_DECLARE(void) gdImageGifAnimAdd(gdImagePtr im, FILE *outFile, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm); +BGD_DECLARE(void) gdImageGifAnimEnd(FILE *outFile); +BGD_DECLARE(void) gdImageGifAnimBeginCtx(gdImagePtr im, gdIOCtx *out, int GlobalCM, int Loops); +BGD_DECLARE(void) gdImageGifAnimAddCtx(gdImagePtr im, gdIOCtx *out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm); +BGD_DECLARE(void) gdImageGifAnimEndCtx(gdIOCtx *out); +BGD_DECLARE(void *) gdImageGifAnimBeginPtr(gdImagePtr im, int *size, int GlobalCM, int Loops); +BGD_DECLARE(void *) gdImageGifAnimAddPtr(gdImagePtr im, int *size, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm); +BGD_DECLARE(void *) gdImageGifAnimEndPtr(int *size); + +/* A custom data sink. For backwards compatibility. Use gdIOCtx + instead. The sink function must return -1 on error, otherwise the + number of bytes written, which must be equal to len. Context will + be passed to your sink function. +*/ +typedef struct { + int (*sink) (void *context, const char *buffer, int len); + void *context; +} +gdSink, *gdSinkPtr; + +BGD_DECLARE(void) gdImagePngToSink (gdImagePtr im, gdSinkPtr out); + +BGD_DECLARE(void) gdImageGd (gdImagePtr im, FILE * out); +BGD_DECLARE(void) gdImageGd2 (gdImagePtr im, FILE * out, int cs, int fmt); + +/* Best to free this memory with gdFree(), not free() */ +BGD_DECLARE(void *) gdImageGifPtr (gdImagePtr im, int *size); + +/* Best to free this memory with gdFree(), not free() */ +BGD_DECLARE(void *) gdImagePngPtr (gdImagePtr im, int *size); +BGD_DECLARE(void *) gdImagePngPtrEx (gdImagePtr im, int *size, int level); + +/* Best to free this memory with gdFree(), not free() */ +BGD_DECLARE(void *) gdImageGdPtr (gdImagePtr im, int *size); + +/* Best to free this memory with gdFree(), not free() */ +BGD_DECLARE(void *) gdImageGd2Ptr (gdImagePtr im, int cs, int fmt, int *size); + +/* Style is a bitwise OR ( | operator ) of these. + gdArc and gdChord are mutually exclusive; + gdChord just connects the starting and ending + angles with a straight line, while gdArc produces + a rounded edge. gdPie is a synonym for gdArc. + gdNoFill indicates that the arc or chord should be + outlined, not filled. gdEdged, used together with + gdNoFill, indicates that the beginning and ending + angles should be connected to the center; this is + a good way to outline (rather than fill) a + 'pie slice'. */ +#define gdArc 0 +#define gdPie gdArc +#define gdChord 1 +#define gdNoFill 2 +#define gdEdged 4 + +BGD_DECLARE(void) gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, + int e, int color, int style); +BGD_DECLARE(void) gdImageArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e, + int color); +BGD_DECLARE(void) gdImageEllipse(gdImagePtr im, int cx, int cy, int w, int h, int color); +BGD_DECLARE(void) gdImageFilledEllipse (gdImagePtr im, int cx, int cy, int w, int h, + int color); +BGD_DECLARE(void) gdImageFillToBorder (gdImagePtr im, int x, int y, int border, + int color); +BGD_DECLARE(void) gdImageFill (gdImagePtr im, int x, int y, int color); +BGD_DECLARE(void) gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, + int srcX, int srcY, int w, int h); +BGD_DECLARE(void) gdImageCopyMerge (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, + int srcX, int srcY, int w, int h, int pct); +BGD_DECLARE(void) gdImageCopyMergeGray (gdImagePtr dst, gdImagePtr src, int dstX, + int dstY, int srcX, int srcY, int w, int h, + int pct); + +/* Stretches or shrinks to fit, as needed. Does NOT attempt + to average the entire set of source pixels that scale down onto the + destination pixel. */ +BGD_DECLARE(void) gdImageCopyResized (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, + int srcX, int srcY, int dstW, int dstH, int srcW, + int srcH); + +/* gd 2.0: stretches or shrinks to fit, as needed. When called with a + truecolor destination image, this function averages the + entire set of source pixels that scale down onto the + destination pixel, taking into account what portion of the + destination pixel each source pixel represents. This is a + floating point operation, but this is not a performance issue + on modern hardware, except for some embedded devices. If the + destination is a palette image, gdImageCopyResized is + substituted automatically. */ +BGD_DECLARE(void) gdImageCopyResampled (gdImagePtr dst, gdImagePtr src, int dstX, + int dstY, int srcX, int srcY, int dstW, int dstH, + int srcW, int srcH); + +/* gd 2.0.8: gdImageCopyRotated is added. Source + is a rectangle, with its upper left corner at + srcX and srcY. Destination is the *center* of + the rotated copy. Angle is in degrees, same as + gdImageArc. Floating point destination center + coordinates allow accurate rotation of + objects of odd-numbered width or height. */ +BGD_DECLARE(void) gdImageCopyRotated (gdImagePtr dst, + gdImagePtr src, + double dstX, double dstY, + int srcX, int srcY, + int srcWidth, int srcHeight, int angle); + +BGD_DECLARE(gdImagePtr) gdImageClone (gdImagePtr src); + +BGD_DECLARE(void) gdImageSetBrush (gdImagePtr im, gdImagePtr brush); +BGD_DECLARE(void) gdImageSetTile (gdImagePtr im, gdImagePtr tile); +BGD_DECLARE(void) gdImageSetAntiAliased (gdImagePtr im, int c); +BGD_DECLARE(void) gdImageSetAntiAliasedDontBlend (gdImagePtr im, int c, int dont_blend); +BGD_DECLARE(void) gdImageSetStyle (gdImagePtr im, int *style, int noOfPixels); +/* Line thickness (defaults to 1). Affects lines, ellipses, + rectangles, polygons and so forth. */ +BGD_DECLARE(void) gdImageSetThickness (gdImagePtr im, int thickness); +/* On or off (1 or 0) for all three of these. */ +BGD_DECLARE(void) gdImageInterlace (gdImagePtr im, int interlaceArg); +BGD_DECLARE(void) gdImageAlphaBlending (gdImagePtr im, int alphaBlendingArg); +BGD_DECLARE(void) gdImageSaveAlpha (gdImagePtr im, int saveAlphaArg); + +BGD_DECLARE(gdImagePtr) gdImageNeuQuant(gdImagePtr im, const int max_color, int sample_factor); + +enum gdPixelateMode { + GD_PIXELATE_UPPERLEFT, + GD_PIXELATE_AVERAGE +}; + +BGD_DECLARE(int) gdImagePixelate(gdImagePtr im, int block_size, const unsigned int mode); + +typedef struct { + int sub; + int plus; + unsigned int num_colors; + int *colors; + unsigned int seed; +} gdScatter, *gdScatterPtr; + +BGD_DECLARE(int) gdImageScatter(gdImagePtr im, int sub, int plus); +BGD_DECLARE(int) gdImageScatterColor(gdImagePtr im, int sub, int plus, int colors[], unsigned int num_colors); +BGD_DECLARE(int) gdImageScatterEx(gdImagePtr im, gdScatterPtr s); +BGD_DECLARE(int) gdImageSmooth(gdImagePtr im, float weight); +BGD_DECLARE(int) gdImageMeanRemoval(gdImagePtr im); +BGD_DECLARE(int) gdImageEmboss(gdImagePtr im); +BGD_DECLARE(int) gdImageGaussianBlur(gdImagePtr im); +BGD_DECLARE(int) gdImageEdgeDetectQuick(gdImagePtr src); +BGD_DECLARE(int) gdImageSelectiveBlur( gdImagePtr src); +BGD_DECLARE(int) gdImageConvolution(gdImagePtr src, float filter[3][3], float filter_div, float offset); +BGD_DECLARE(int) gdImageColor(gdImagePtr src, const int red, const int green, const int blue, const int alpha); +BGD_DECLARE(int) gdImageContrast(gdImagePtr src, double contrast); +BGD_DECLARE(int) gdImageBrightness(gdImagePtr src, int brightness); +BGD_DECLARE(int) gdImageGrayScale(gdImagePtr src); +BGD_DECLARE(int) gdImageNegate(gdImagePtr src); + +/* Macros to access information about images. */ + +/* Returns nonzero if the image is a truecolor image, + zero for a palette image. */ +#define gdImageTrueColor(im) ((im)->trueColor) + +#define gdImageSX(im) ((im)->sx) +#define gdImageSY(im) ((im)->sy) +#define gdImageColorsTotal(im) ((im)->colorsTotal) +#define gdImageRed(im, c) ((im)->trueColor ? gdTrueColorGetRed(c) : \ + (im)->red[(c)]) +#define gdImageGreen(im, c) ((im)->trueColor ? gdTrueColorGetGreen(c) : \ + (im)->green[(c)]) +#define gdImageBlue(im, c) ((im)->trueColor ? gdTrueColorGetBlue(c) : \ + (im)->blue[(c)]) +#define gdImageAlpha(im, c) ((im)->trueColor ? gdTrueColorGetAlpha(c) : \ + (im)->alpha[(c)]) +#define gdImageGetTransparent(im) ((im)->transparent) +#define gdImageGetInterlaced(im) ((im)->interlace) + +/* These macros provide direct access to pixels in + palette-based and truecolor images, respectively. + If you use these macros, you must perform your own + bounds checking. Use of the macro for the correct type + of image is also your responsibility. */ +#define gdImagePalettePixel(im, x, y) (im)->pixels[(y)][(x)] +#define gdImageTrueColorPixel(im, x, y) (im)->tpixels[(y)][(x)] + +#define gdImageResolutionX(im) (im)->res_x +#define gdImageResolutionY(im) (im)->res_y + +/* I/O Support routines. */ + +BGD_DECLARE(gdIOCtx *) gdNewFileCtx (FILE *); +/* If data is null, size is ignored and an initial data buffer is + allocated automatically. NOTE: this function assumes gd has the right + to free or reallocate "data" at will! Also note that gd will free + "data" when the IO context is freed. If data is not null, it must point + to memory allocated with gdMalloc, or by a call to gdImage[something]Ptr. + If not, see gdNewDynamicCtxEx for an alternative. */ +BGD_DECLARE(gdIOCtx *) gdNewDynamicCtx (int size, void *data); +/* 2.0.21: if freeFlag is nonzero, gd will free and/or reallocate "data" as + needed as described above. If freeFlag is zero, gd will never free + or reallocate "data", which means that the context should only be used + for *reading* an image from a memory buffer, or writing an image to a + memory buffer which is already large enough. If the memory buffer is + not large enough and an image write is attempted, the write operation + will fail. Those wishing to write an image to a buffer in memory have + a much simpler alternative in the gdImage[something]Ptr functions. */ +BGD_DECLARE(gdIOCtx *) gdNewDynamicCtxEx (int size, void *data, int freeFlag); +BGD_DECLARE(gdIOCtx *) gdNewSSCtx (gdSourcePtr in, gdSinkPtr out); +BGD_DECLARE(void *) gdDPExtractData (struct gdIOCtx *ctx, int *size); + +#define GD2_CHUNKSIZE 128 +#define GD2_CHUNKSIZE_MIN 64 +#define GD2_CHUNKSIZE_MAX 4096 + +#define GD2_VERS 2 +#define GD2_ID "gd2" + +#define GD2_FMT_RAW 1 +#define GD2_FMT_COMPRESSED 2 + +/* Image comparison definitions */ +BGD_DECLARE(int) gdImageCompare (gdImagePtr im1, gdImagePtr im2); + +BGD_DECLARE(void) gdImageFlipHorizontal(gdImagePtr im); +BGD_DECLARE(void) gdImageFlipVertical(gdImagePtr im); +BGD_DECLARE(void) gdImageFlipBoth(gdImagePtr im); + +#define GD_FLIP_HORINZONTAL 1 +#define GD_FLIP_VERTICAL 2 +#define GD_FLIP_BOTH 3 + +/** + * Group: Crop + * + * Constants: gdCropMode + * GD_CROP_DEFAULT - Default crop mode (4 corners or background) + * GD_CROP_TRANSPARENT - Crop using the transparent color + * GD_CROP_BLACK - Crop black borders + * GD_CROP_WHITE - Crop white borders + * GD_CROP_SIDES - Crop using colors of the 4 corners + * + * See also: + * + **/ +enum gdCropMode { + GD_CROP_DEFAULT = 0, + GD_CROP_TRANSPARENT, + GD_CROP_BLACK, + GD_CROP_WHITE, + GD_CROP_SIDES, + GD_CROP_THRESHOLD +}; + +BGD_DECLARE(gdImagePtr) gdImageCrop(gdImagePtr src, const gdRect *crop); +BGD_DECLARE(gdImagePtr) gdImageCropAuto(gdImagePtr im, const unsigned int mode); +BGD_DECLARE(gdImagePtr) gdImageCropThreshold(gdImagePtr im, const unsigned int color, const float threshold); + +BGD_DECLARE(int) gdImageSetInterpolationMethod(gdImagePtr im, gdInterpolationMethod id); + +gdImagePtr gdImageScaleBilinear(gdImagePtr im, const unsigned int new_width, const unsigned int new_height); +gdImagePtr gdImageScaleBicubic(gdImagePtr src_img, const unsigned int new_width, const unsigned int new_height); +gdImagePtr gdImageScaleBicubicFixed(gdImagePtr src, const unsigned int width, const unsigned int height); +gdImagePtr gdImageScaleNearestNeighbour(gdImagePtr im, const unsigned int width, const unsigned int height); +gdImagePtr gdImageScaleTwoPass(const gdImagePtr pOrigImage, const unsigned int uOrigWidth, const unsigned int uOrigHeight, const unsigned int uNewWidth, const unsigned int uNewHeight); +BGD_DECLARE(gdImagePtr) gdImageScale(const gdImagePtr src, const unsigned int new_width, const unsigned int new_height); + +gdImagePtr gdImageRotate90(gdImagePtr src, int ignoretransparent); +gdImagePtr gdImageRotate180(gdImagePtr src, int ignoretransparent); +gdImagePtr gdImageRotate270(gdImagePtr src, int ignoretransparent); +gdImagePtr gdImageRotateNearestNeighbour(gdImagePtr src, const float degrees, const int bgColor); +gdImagePtr gdImageRotateBilinear(gdImagePtr src, const float degrees, const int bgColor); +gdImagePtr gdImageRotateBicubicFixed(gdImagePtr src, const float degrees, const int bgColor); +gdImagePtr gdImageRotateGeneric(gdImagePtr src, const float degrees, const int bgColor); +BGD_DECLARE(gdImagePtr) gdImageRotateInterpolated(const gdImagePtr src, const float angle, int bgcolor); + +typedef enum { + GD_AFFINE_TRANSLATE = 0, + GD_AFFINE_SCALE, + GD_AFFINE_ROTATE, + GD_AFFINE_SHEAR_HORIZONTAL, + GD_AFFINE_SHEAR_VERTICAL +} gdAffineStandardMatrix; + +BGD_DECLARE(int) gdAffineApplyToPointF (gdPointFPtr dst, const gdPointFPtr src, const double affine[6]); +BGD_DECLARE(int) gdAffineInvert (double dst[6], const double src[6]); +BGD_DECLARE(int) gdAffineFlip (double dst_affine[6], const double src_affine[6], const int flip_h, const int flip_v); +BGD_DECLARE(int) gdAffineConcat (double dst[6], const double m1[6], const double m2[6]); + +BGD_DECLARE(int) gdAffineIdentity (double dst[6]); +BGD_DECLARE(int) gdAffineScale (double dst[6], const double scale_x, const double scale_y); +BGD_DECLARE(int) gdAffineRotate (double dst[6], const double angle); +BGD_DECLARE(int) gdAffineShearHorizontal (double dst[6], const double angle); +BGD_DECLARE(int) gdAffineShearVertical(double dst[6], const double angle); +BGD_DECLARE(int) gdAffineTranslate (double dst[6], const double offset_x, const double offset_y); +BGD_DECLARE(double) gdAffineExpansion (const double src[6]); +BGD_DECLARE(int) gdAffineRectilinear (const double src[6]); +BGD_DECLARE(int) gdAffineEqual (const double matrix1[6], const double matrix2[6]); +BGD_DECLARE(int) gdTransformAffineGetImage(gdImagePtr *dst, const gdImagePtr src, gdRectPtr src_area, const double affine[6]); +BGD_DECLARE(int) gdTransformAffineCopy(gdImagePtr dst, int dst_x, int dst_y, const gdImagePtr src, gdRectPtr src_region, const double affine[6]); +/* +gdTransformAffineCopy(gdImagePtr dst, int x0, int y0, int x1, int y1, + const gdImagePtr src, int src_width, int src_height, + const double affine[6]); +*/ +BGD_DECLARE(int) gdTransformAffineBoundingBox(gdRectPtr src, const double affine[6], gdRectPtr bbox); + +#define GD_CMP_IMAGE 1 /* Actual image IS different */ +#define GD_CMP_NUM_COLORS 2 /* Number of Colours in pallette differ */ +#define GD_CMP_COLOR 4 /* Image colours differ */ +#define GD_CMP_SIZE_X 8 /* Image width differs */ +#define GD_CMP_SIZE_Y 16 /* Image heights differ */ +#define GD_CMP_TRANSPARENT 32 /* Transparent colour */ +#define GD_CMP_BACKGROUND 64 /* Background colour */ +#define GD_CMP_INTERLACE 128 /* Interlaced setting */ +#define GD_CMP_TRUECOLOR 256 /* Truecolor vs palette differs */ + +/* resolution affects ttf font rendering, particularly hinting */ +#define GD_RESOLUTION 96 /* pixels per inch */ + +#ifdef __cplusplus +} +#endif + +/* newfangled special effects */ +#include "gdfx.h" + +#endif /* GD_H */ + +#ifdef __cplusplus +} +#endif debian/patches/CVE-2015-8877.patch0000644000000000000000000000210612721575022013255 0ustar Backport of: From 4751b606fa38edc456d627140898a7ec679fcc24 Mon Sep 17 00:00:00 2001 From: Vladimir Mitrovic Date: Wed, 5 Aug 2015 03:01:06 +0200 Subject: [PATCH] gdImageScaleTwoPass memory leak fix Fixing memory leak in gdImageScaleTwoPass, as reported by @cmb69 and confirmed by @vapier. This bug actually bit me in production and I'm very thankful that it was reported with an easy fix. Fixes #173. --- src/gd_interpolation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: libgd2-2.1.0/src/gd_interpolation.c =================================================================== --- libgd2-2.1.0.orig/src/gd_interpolation.c 2016-05-26 09:27:43.217119308 -0400 +++ libgd2-2.1.0/src/gd_interpolation.c 2016-05-26 09:28:30.473748958 -0400 @@ -1087,11 +1087,11 @@ dst = gdImageCreateTrueColor(new_width, new_height); if (dst == NULL) { - gdFree(tmp_im); + gdImageDestroy(tmp_im); return NULL; } _gdScaleVert(tmp_im, new_width, src_height, dst, new_width, new_height); - gdFree(tmp_im); + gdImageDestroy(tmp_im); return dst; } debian/patches/CVE-2016-6214.patch0000644000000000000000000000365612752376667013272 0ustar Description: fix out-of-bounds read issue with unsupported TGA bpp/alphabit combinations Origin: backport, https://github.com/libgd/libgd/commit/2733b623ee08eca6b277ad8b0b89251462c09435 Origin: backport, https://github.com/libgd/libgd/commit/cb1a0b7e54e9aa118270c23a4a6fe560e4590dc9 Index: libgd2-2.1.1/src/gd_tga.c =================================================================== --- libgd2-2.1.1.orig/src/gd_tga.c 2016-08-09 11:50:06.689180635 -0400 +++ libgd2-2.1.1/src/gd_tga.c 2016-08-09 11:51:46.698468632 -0400 @@ -61,7 +61,7 @@ tga->bitmap = NULL; tga->ident = NULL; - if (!read_header_tga(ctx, tga)) { + if (read_header_tga(ctx, tga) < 0) { free_tga(tga); return NULL; } @@ -71,7 +71,7 @@ image_block_size = (tga->width * tga->height) * pixel_block_size; */ - if (read_image_tga(ctx, tga)) { + if (read_image_tga(ctx, tga) < 0) { free_tga(tga); return NULL; } @@ -99,7 +99,7 @@ if (tga->bits == TGA_BPP_24) { *tpix = gdTrueColor(tga->bitmap[bitmap_caret + 2], tga->bitmap[bitmap_caret + 1], tga->bitmap[bitmap_caret]); bitmap_caret += 3; - } else if (tga->bits == TGA_BPP_32 || tga->alphabits) { + } else if (tga->bits == TGA_BPP_32 && tga->alphabits) { register int a = tga->bitmap[bitmap_caret + 3]; *tpix = gdTrueColorAlpha(tga->bitmap[bitmap_caret + 2], tga->bitmap[bitmap_caret + 1], tga->bitmap[bitmap_caret], gdAlphaMax - (a >> 1)); @@ -159,16 +159,12 @@ int read_header_tga(gdIOCtx *ctx, oTga *tga) printf("wxh: %i %i\n", tga->width, tga->height); #endif - switch(tga->bits) { - case 8: - case 16: - case 24: - case 32: - break; - default: - gd_error("bps %i not supported", tga->bits); + if (!((tga->bits == TGA_BPP_24 && tga->alphabits == 0) + || (tga->bits == TGA_BPP_32 && tga->alphabits == 8))) + { + gd_error_ex(GD_WARNING, "gd-tga: %u bits per pixel with %u alpha bits not supported\n", + tga->bits, tga->alphabits); return -1; - break; } tga->ident = NULL; debian/patches/CVE-2016-5116.patch0000644000000000000000000000513612737771727013264 0ustar From 4dc1a2d7931017d3625f2d7cff70a17ce58b53b4 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 14 May 2016 01:38:18 -0400 Subject: [PATCH] xbm: avoid stack overflow (read) with large names #211 We use the name passed in to printf into a local stack buffer which is limited to 4000 bytes. So given a large enough value, lots of stack data is leaked. Rewrite the code to do simple memory copies with most of the strings to avoid that issue, and only use stack buffer for small numbers of constant size. This closes #211. --- src/gd_xbm.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) Index: libgd2-2.1.0/src/gd_xbm.c =================================================================== --- libgd2-2.1.0.orig/src/gd_xbm.c 2016-07-08 14:41:24.683135594 -0400 +++ libgd2-2.1.0/src/gd_xbm.c 2016-07-08 14:41:24.679135543 -0400 @@ -147,7 +147,7 @@ /* {{{ gdCtxPrintf */ static void gdCtxPrintf(gdIOCtx * out, const char *format, ...) { - char buf[4096]; + char buf[1024]; int len; va_list args; @@ -158,6 +158,9 @@ } /* }}} */ +/* The compiler will optimize strlen(constant) to a constant number. */ +#define gdCtxPuts(out, s) out->putBuf(out, s, strlen(s)) + /* {{{ gdImageXbmCtx */ BGD_DECLARE(void) gdImageXbmCtx(gdImagePtr image, char* file_name, int fg, gdIOCtx * out) { @@ -182,9 +185,26 @@ } } - gdCtxPrintf(out, "#define %s_width %d\n", name, gdImageSX(image)); - gdCtxPrintf(out, "#define %s_height %d\n", name, gdImageSY(image)); - gdCtxPrintf(out, "static unsigned char %s_bits[] = {\n ", name); + /* Since "name" comes from the user, run it through a direct puts. + * Trying to printf it into a local buffer means we'd need a large + * or dynamic buffer to hold it all. */ + + /* #define _width 1234 */ + gdCtxPuts(out, "#define "); + gdCtxPuts(out, name); + gdCtxPuts(out, "_width "); + gdCtxPrintf(out, "%d\n", gdImageSX(image)); + + /* #define _height 1234 */ + gdCtxPuts(out, "#define "); + gdCtxPuts(out, name); + gdCtxPuts(out, "_height "); + gdCtxPrintf(out, "%d\n", gdImageSY(image)); + + /* static unsigned char _bits[] = {\n */ + gdCtxPuts(out, "static unsigned char "); + gdCtxPuts(out, name); + gdCtxPuts(out, "_bits[] = {\n "); free(name); @@ -201,9 +221,9 @@ if ((b == 128) || (x == sx && y == sy)) { b = 1; if (p) { - gdCtxPrintf(out, ", "); + gdCtxPuts(out, ", "); if (!(p%12)) { - gdCtxPrintf(out, "\n "); + gdCtxPuts(out, "\n "); p = 12; } } @@ -215,6 +235,6 @@ } } } - gdCtxPrintf(out, "};\n"); + gdCtxPuts(out, "};\n"); } /* }}} */ debian/patches/CVE-2016-9933.patch0000644000000000000000000000211113055314444013244 0ustar From 77f619d48259383628c3ec4654b1ad578e9eb40e Mon Sep 17 00:00:00 2001 From: Pierre Joye Date: Sat, 4 Jun 2016 23:09:01 +0700 Subject: [PATCH] fix #215 gdImageFillToBorder stack-overflow when invalid color is used --- src/gd.c | 8 +++++++- tests/gdimagefilltoborder/.gitignore | 1 + tests/gdimagefilltoborder/CMakeLists.txt | 1 + tests/gdimagefilltoborder/Makemodule.am | 3 ++- 4 files changed, 11 insertions(+), 2 deletions(-) Index: libgd2-2.1.0/src/gd.c =================================================================== --- libgd2-2.1.0.orig/src/gd.c 2017-02-28 10:37:06.699089974 -0500 +++ libgd2-2.1.0/src/gd.c 2017-02-28 10:37:06.687089831 -0500 @@ -1834,11 +1834,17 @@ int i; int restoreAlphaBleding; - if (border < 0) { + if (border < 0 || color < 0) { /* Refuse to fill to a non-solid border */ return; } + if (!im->trueColor) { + if ((color > (im->colorsTotal - 1)) || (border > (im->colorsTotal - 1))) { + return; + } + } + leftLimit = (-1); restoreAlphaBleding = im->alphaBlendingFlag; debian/patches/CVE-2016-8670.patch0000644000000000000000000000120513001411362013230 0ustar From: Emmanuel Date: Tue, 11 Oct 2016 19:08:03 +1300 Subject: Patch for security bug https://bugs.php.net/bug.php?id=73280 --- src/gd_io_dp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gd_io_dp.c b/src/gd_io_dp.c index 8dbcc62..0219733 100644 --- a/src/gd_io_dp.c +++ b/src/gd_io_dp.c @@ -266,7 +266,7 @@ static int dynamicGetbuf(gdIOCtxPtr ctx, void *buf, int len) if(remain >= len) { rlen = len; } else { - if(remain == 0) { + if(remain <= 0) { /* 2.0.34: EOF is incorrect. We use 0 for * errors and EOF, just like fileGetbuf, * which is a simple fread() wrapper. debian/patches/CVE-2016-6128.patch0000644000000000000000000000453712737771737013275 0ustar Description: fix denial of service via invalid color index Origin: backport, https://github.com/libgd/libgd/compare/3fe0a7128bac5000fdcfab888bd2a75ec0c9447d...fd623025505e87bba7ec8555eeb72dae4fb0afd Bug: https://bugs.php.net/bug.php?id=72494 Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=829062 Index: libgd2-2.1.1/src/gd_crop.c =================================================================== --- libgd2-2.1.1.orig/src/gd_crop.c 2016-07-08 14:18:17.453240529 -0400 +++ libgd2-2.1.1/src/gd_crop.c 2016-07-08 14:18:17.449240477 -0400 @@ -136,6 +136,10 @@ return NULL; } + if (!gdImageTrueColor(im) && color >= gdImageColorsTotal(im)) { + return NULL; + } + /* TODO: Add gdImageGetRowPtr and works with ptr at the row level * for the true color and palette images * new formats will simply work with ptr Index: libgd2-2.1.1/tests/CMakeLists.txt =================================================================== --- libgd2-2.1.1.orig/tests/CMakeLists.txt 2016-07-08 14:18:17.453240529 -0400 +++ libgd2-2.1.1/tests/CMakeLists.txt 2016-07-08 14:18:54.461711711 -0400 @@ -31,6 +31,7 @@ gdimagecolortransparent gdimagecopy gdimagecopyrotated + gdimagecrop gdimagefill gdimagefilledellipse gdimagefilledpolygon Index: libgd2-2.1.1/tests/Makefile.am =================================================================== --- libgd2-2.1.1.orig/tests/Makefile.am 2016-07-08 14:18:17.453240529 -0400 +++ libgd2-2.1.1/tests/Makefile.am 2016-07-08 14:22:22.740361562 -0400 @@ -17,6 +17,7 @@ tga/tga_null \ gdimagepixelate/gdimagepixelate \ gdimagecopy/bug00007 \ + gdimagecrop/php_bug_72494 \ gdnewfilectx/gdnewfilectx_null \ gdimagefilledrectangle/bug00078 \ gdimagefilledrectangle/bug00004 \ Index: libgd2-2.1.1/tests/gdimagecrop/php_bug_72494.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ libgd2-2.1.1/tests/gdimagecrop/php_bug_72494.c 2016-07-08 14:18:17.449240477 -0400 @@ -0,0 +1,22 @@ +#include +#include +#include "gd.h" + +#include "gdtest.h" + +int main() +{ + gdImagePtr im; + + im = gdImageCreate(50, 50); + + if (!im) { + gdTestErrorMsg("gdImageCreate failed.\n"); + return 1; + } + + gdImageCropThreshold(im, 1337, 0); + gdImageDestroy(im); + /* this bug tests a crash, it never reaches this point if the bug exists*/ + return 0; +} debian/patches/CVE-2018-1000222.patch0000644000000000000000000000425113337535672013467 0ustar From ac16bdf2d41724b5a65255d4c28fb0ec46bc42f5 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 14 Jul 2018 13:54:08 -0400 Subject: [PATCH] bmp: check return value in gdImageBmpPtr Closes #447. diff --git a/src/gd_bmp.c b/src/gd_bmp.c index 0fc0219..b73a93f 100644 --- a/src/gd_bmp.c +++ b/src/gd_bmp.c @@ -40,6 +40,8 @@ static int bmp_read_4bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp static int bmp_read_8bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp_hdr_t *header); static int bmp_read_rle(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info); +static int _gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression); + #define BMP_DEBUG(s) static int gdBMPPutWord(gdIOCtx *out, int w) @@ -65,8 +67,10 @@ BGD_DECLARE(void *) gdImageBmpPtr(gdImagePtr im, int *size, int compression) void *rv; gdIOCtx *out = gdNewDynamicCtx(2048, NULL); if (out == NULL) return NULL; - gdImageBmpCtx(im, out, compression); - rv = gdDPExtractData(out, size); + if (!_gdImageBmpCtx(im, out, compression)) + rv = gdDPExtractData(out, size); + else + rv = NULL; out->gd_free(out); return rv; } @@ -81,12 +85,18 @@ BGD_DECLARE(void) gdImageBmp(gdImagePtr im, FILE *outFile, int compression) BGD_DECLARE(void) gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression) { + _gdImageBmpCtx(im, out, compression); +} + +static int _gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression) +{ int bitmap_size = 0, info_size, total_size, padding; int i, row, xpos, pixel; int error = 0; unsigned char *uncompressed_row = NULL, *uncompressed_row_start = NULL; FILE *tmpfile_for_compression = NULL; gdIOCtxPtr out_original = NULL; + int ret = 1; /* No compression if its true colour or we don't support seek */ if (im->trueColor) { @@ -263,7 +273,7 @@ BGD_DECLARE(void) gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression) out = out_original; out_original = NULL; } - + ret = 0; cleanup: if (tmpfile_for_compression) { #ifdef _WIN32 @@ -277,7 +287,7 @@ cleanup: if (out_original) { out_original->gd_free(out_original); } - return; + return ret; } static int compress_row(unsigned char *row, int length) debian/patches/CVE-2015-8874.patch0000644000000000000000000000150612721574707013266 0ustar From 38241013cc048af7c03daf6e9a75b4f42bffb200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 20 May 2016 09:39:38 +0200 Subject: [PATCH] CVE-2015-8874 --- src/gd.c | 11 +++++++++++ 1 file changed, 11 insertions(+) Index: libgd2-2.1.0/src/gd.c =================================================================== --- libgd2-2.1.0.orig/src/gd.c 2016-05-26 09:27:33.100984443 -0400 +++ libgd2-2.1.0/src/gd.c 2016-05-26 09:27:33.096984389 -0400 @@ -1840,6 +1840,17 @@ restoreAlphaBleding = im->alphaBlendingFlag; im->alphaBlendingFlag = 0; + if (x >= im->sx) { + x = im->sx - 1; + } else if (x < 0) { + x = 0; + } + if (y >= im->sy) { + y = im->sy - 1; + } else if (y < 0) { + y = 0; + } + for (i = x; (i >= 0); i--) { if (gdImageGetPixel (im, i, y) == border) { break; debian/patches/CVE-2016-6207.patch0000644000000000000000000002324412752361110013240 0ustar Description: fix OOB or OOM in gdImageScale Origin: backport, https://github.com/libgd/libgd/commit/0dd40abd6d5b3e53a6b745dd4d6cf94b70010989 Origin: backport, https://github.com/libgd/libgd/commit/d325888a9fe3c9681e4a9aad576de2c5cd5df2ef Origin: backport, https://github.com/libgd/libgd/commit/ff9113c80a32205d45205d3ea30965b25480e0fb Origin: backport, https://github.com/libgd/libgd/commit/f60ec7a546499f9446063a4dbe755be9523d8232 Origin: backport, https://github.com/libgd/libgd/commit/7a28c235890c95e6010e7b0d0f7c7369367168ef Origin: backport, https://github.com/libgd/libgd/commit/0dd1706c14abced200f8e5f83d2f86dc44cd9508 Origin: backport, https://github.com/libgd/libgd/commit/8b7e76dd370e068515162e74986f7968dddc7384 Bug-PHP: https://bugs.php.net/bug.php?id=72558 Index: libgd2-2.1.0/src/gd.c =================================================================== --- libgd2-2.1.0.orig/src/gd.c 2016-08-09 10:01:26.494915347 -0400 +++ libgd2-2.1.0/src/gd.c 2016-08-09 10:01:26.490915294 -0400 @@ -207,7 +207,7 @@ return 0; } - if (overflow2(sizeof(int), sx)) { + if (overflow2(sizeof(int *), sx)) { return NULL; } @@ -2781,78 +2781,77 @@ int dstW, int dstH, int srcW, int srcH) { int x, y; - double sy1, sy2, sx1, sx2; if (!dst->trueColor) { - gdImageCopyResized (dst, src, dstX, dstY, srcX, srcY, dstW, dstH, - srcW, srcH); + gdImageCopyResized (dst, src, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH); return; } for (y = dstY; (y < dstY + dstH); y++) { - sy1 = ((double) y - (double) dstY) * (double) srcH / (double) dstH; - sy2 = ((double) (y + 1) - (double) dstY) * (double) srcH / - (double) dstH; for (x = dstX; (x < dstX + dstW); x++) { - double sx, sy; - double spixels = 0; - double red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0; - double alpha_sum = 0.0, contrib_sum = 0.0; - - sx1 = ((double) x - (double) dstX) * (double) srcW / dstW; - sx2 = ((double) (x + 1) - (double) dstX) * (double) srcW / dstW; + float sy1, sy2, sx1, sx2; + float sx, sy; + float spixels = 0.0; + float red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0; + float alpha_factor, alpha_sum = 0.0, contrib_sum = 0.0; + sy1 = ((float)(y - dstY)) * (float)srcH / (float)dstH; + sy2 = ((float)(y + 1 - dstY)) * (float) srcH / (float) dstH; sy = sy1; do { - double yportion; - if (floor2 (sy) == floor2 (sy1)) { - yportion = 1.0 - (sy - floor2 (sy)); + float yportion; + if (floorf(sy) == floorf(sy1)) { + yportion = 1.0 - (sy - floorf(sy)); if (yportion > sy2 - sy1) { yportion = sy2 - sy1; } - sy = floor2 (sy); - } else if (sy == floor2 (sy2)) { - yportion = sy2 - floor2 (sy2); + sy = floorf(sy); + } else if (sy == floorf(sy2)) { + yportion = sy2 - floorf(sy2); } else { yportion = 1.0; } + sx1 = ((float)(x - dstX)) * (float) srcW / dstW; + sx2 = ((float)(x + 1 - dstX)) * (float) srcW / dstW; sx = sx1; do { - double xportion; - double pcontribution; + float xportion; + float pcontribution; int p; - if (floor2 (sx) == floor2 (sx1)) { - xportion = 1.0 - (sx - floor2 (sx)); + if (floorf(sx) == floorf(sx1)) { + xportion = 1.0 - (sx - floorf(sx)); if (xportion > sx2 - sx1) { xportion = sx2 - sx1; } - sx = floor2 (sx); - } else if (sx == floor2 (sx2)) { - xportion = sx2 - floor2 (sx2); + sx = floorf(sx); + } else if (sx == floorf(sx2)) { + xportion = sx2 - floorf(sx2); } else { xportion = 1.0; } pcontribution = xportion * yportion; - /* 2.08: previously srcX and srcY were ignored. - Andrew Pattison */ - p = gdImageGetTrueColorPixel (src, - (int) sx + srcX, - (int) sy + srcY); - red += gdTrueColorGetRed (p) * pcontribution; - green += gdTrueColorGetGreen (p) * pcontribution; - blue += gdTrueColorGetBlue (p) * pcontribution; + p = gdImageGetTrueColorPixel(src, (int) sx + srcX, (int) sy + srcY); + + alpha_factor = ((gdAlphaMax - gdTrueColorGetAlpha(p))) * pcontribution; + red += gdTrueColorGetRed (p) * alpha_factor; + green += gdTrueColorGetGreen (p) * alpha_factor; + blue += gdTrueColorGetBlue (p) * alpha_factor; alpha += gdTrueColorGetAlpha (p) * pcontribution; + alpha_sum += alpha_factor; + contrib_sum += pcontribution; spixels += xportion * yportion; sx += 1.0; - } while (sx < sx2); - sy += 1.0; - } while (sy < sy2); + } + while (sx < sx2); + sy += 1.0f; + } + while (sy < sy2); + if (spixels != 0.0) { red /= spixels; green /= spixels; blue /= spixels; alpha /= spixels; - alpha += 0.5; } - if ( alpha_sum != 0.0f) { - if( contrib_sum != 0.0f) { + if ( alpha_sum != 0.0) { + if( contrib_sum != 0.0) { alpha_sum /= contrib_sum; } red /= alpha_sum; @@ -2866,17 +2865,13 @@ if (green > 255.0) { green = 255.0; } - if (blue > 255.0) { + if (blue > 255.0f) { blue = 255.0; } if (alpha > gdAlphaMax) { alpha = gdAlphaMax; } - gdImageSetPixel (dst, - x, y, - gdTrueColorAlpha ((int) red, - (int) green, - (int) blue, (int) alpha)); + gdImageSetPixel(dst, x, y, gdTrueColorAlpha ((int) red, (int) green, (int) blue, (int) alpha)); } } } Index: libgd2-2.1.0/src/gd_interpolation.c =================================================================== --- libgd2-2.1.0.orig/src/gd_interpolation.c 2016-08-09 10:01:26.494915347 -0400 +++ libgd2-2.1.0/src/gd_interpolation.c 2016-08-09 10:01:38.947079605 -0400 @@ -901,6 +901,7 @@ { unsigned int u = 0; LineContribType *res; + int overflow_error = 0; res = (LineContribType *) gdMalloc(sizeof(LineContribType)); if (!res) { @@ -908,10 +909,31 @@ } res->WindowSize = windows_size; res->LineLength = line_length; + if (overflow2(line_length, sizeof(ContributionType))) { + gdFree(res); + return NULL; + } res->ContribRow = (ContributionType *) gdMalloc(line_length * sizeof(ContributionType)); - + if (res->ContribRow == NULL) { + gdFree(res); + return NULL; + } for (u = 0 ; u < line_length ; u++) { - res->ContribRow[u].Weights = (double *) gdMalloc(windows_size * sizeof(double)); + if (overflow2(windows_size, sizeof(double))) { + overflow_error = 1; + } else { + res->ContribRow[u].Weights = (double *) gdMalloc(windows_size * sizeof(double)); + } + if (overflow_error == 1 || res->ContribRow[u].Weights == NULL) { + unsigned int i; + u--; + for (i=0;i<=u;i++) { + gdFree(res->ContribRow[i].Weights); + } + gdFree(res->ContribRow); + gdFree(res); + return NULL; + } } return res; } @@ -944,7 +966,9 @@ windows_size = 2 * (int)ceil(width_d) + 1; res = _gdContributionsAlloc(line_size, windows_size); - + if (res == NULL) { + return NULL; + } for (u = 0; u < line_size; u++) { const double dCenter = (double)u / scale_d; /* get the significant edge points affecting the pixel */ @@ -1007,7 +1031,7 @@ } } -static inline void _gdScaleHoriz(gdImagePtr pSrc, unsigned int src_width, unsigned int src_height, gdImagePtr pDst, unsigned int dst_width, unsigned int dst_height) +static inline int _gdScaleHoriz(gdImagePtr pSrc, unsigned int src_width, unsigned int src_height, gdImagePtr pDst, unsigned int dst_width, unsigned int dst_height) { unsigned int u; LineContribType * contrib; @@ -1022,13 +1046,14 @@ contrib = _gdContributionsCalc(dst_width, src_width, (double)dst_width / (double)src_width, pSrc->interpolation); if (contrib == NULL) { - return; + return 0; } /* Scale each row */ for (u = 0; u < dst_height - 1; u++) { _gdScaleRow(pSrc, src_width, pDst, dst_width, u, contrib); } _gdContributionsFree (contrib); + return 1; } static inline void _gdScaleCol (gdImagePtr pSrc, unsigned int src_width, gdImagePtr pRes, unsigned int dst_width, unsigned int dst_height, unsigned int uCol, LineContribType *contrib) @@ -1053,7 +1078,7 @@ } } -static inline void _gdScaleVert (const gdImagePtr pSrc, const unsigned int src_width, const unsigned int src_height, const gdImagePtr pDst, const unsigned int dst_width, const unsigned int dst_height) +static inline int _gdScaleVert (const gdImagePtr pSrc, const unsigned int src_width, const unsigned int src_height, const gdImagePtr pDst, const unsigned int dst_width, const unsigned int dst_height) { unsigned int u; LineContribType * contrib; @@ -1067,11 +1092,15 @@ } contrib = _gdContributionsCalc(dst_height, src_height, (double)(dst_height) / (double)(src_height), pSrc->interpolation); + if (contrib == NULL) { + return 0; + } /* scale each column */ for (u = 0; u < dst_width - 1; u++) { _gdScaleCol(pSrc, src_width, pDst, dst_width, dst_height, u, contrib); } _gdContributionsFree(contrib); + return 1; } gdImagePtr gdImageScaleTwoPass(const gdImagePtr src, const unsigned int src_width, const unsigned int src_height, const unsigned int new_width, const unsigned int new_height) @@ -1083,14 +1112,22 @@ if (tmp_im == NULL) { return NULL; } - _gdScaleHoriz(src, src_width, src_height, tmp_im, new_width, src_height); + if (!_gdScaleHoriz(src, src_width, src_height, tmp_im, new_width, src_height)) { + gdImageDestroy(tmp_im); + return NULL; + } dst = gdImageCreateTrueColor(new_width, new_height); if (dst == NULL) { gdImageDestroy(tmp_im); return NULL; } - _gdScaleVert(tmp_im, new_width, src_height, dst, new_width, new_height); + if (!_gdScaleVert(tmp_im, new_width, src_height, dst, new_width, new_height)) { + gdImageDestroy(tmp_im); + gdImageDestroy(dst); + return NULL; + } + gdImageDestroy(tmp_im); return dst; debian/patches/CVE-2016-6911.patch0000644000000000000000000001035013001411370013224 0ustar From: "Christoph M. Becker" Date: Tue, 2 Aug 2016 12:10:33 +0200 Subject: Fix invalid read in gdImageCreateFromTiffPtr() tiff_invalid_read.tiff is corrupt, and causes an invalid read in gdImageCreateFromTiffPtr(), but not in gdImageCreateFromTiff(). The culprit is dynamicGetbuf(), which doesn't check for out-of-bound reads. In this case, dynamicGetbuf() is called with a negative dp->pos, but also positive buffer overflows have to be handled, in which case 0 has to be returned (cf. commit 75e29a9). Fixing dynamicGetbuf() exhibits that the corrupt TIFF would still create the image, because the return value of TIFFReadRGBAImage() is not checked. We do that, and let createFromTiffRgba() fail if TIFFReadRGBAImage() fails. This issue had been reported by Ibrahim El-Sayed to security@libgd.org. --- src/gd_io_dp.c | 15 ++++++--- src/gd_tiff.c | 27 +++++++++------- tests/tiff/CMakeLists.txt | 1 + tests/tiff/tiff_invalid_read.c | 61 ++++++++++++++++++++++++++++++++++++ tests/tiff/tiff_invalid_read_1.tiff | Bin 0 -> 3304 bytes tests/tiff/tiff_invalid_read_2.tiff | Bin 0 -> 429 bytes tests/tiff/tiff_invalid_read_3.tiff | Bin 0 -> 428 bytes 7 files changed, 87 insertions(+), 17 deletions(-) create mode 100644 tests/tiff/tiff_invalid_read.c create mode 100644 tests/tiff/tiff_invalid_read_1.tiff create mode 100644 tests/tiff/tiff_invalid_read_2.tiff create mode 100644 tests/tiff/tiff_invalid_read_3.tiff Index: libgd2-2.1.1/src/gd_io_dp.c =================================================================== --- libgd2-2.1.1.orig/src/gd_io_dp.c 2016-10-18 14:16:28.629017465 +0200 +++ libgd2-2.1.1/src/gd_io_dp.c 2016-10-18 14:16:28.629017465 +0200 @@ -253,6 +253,7 @@ appendDynamic(dctx->dp, &b, 1); } +/* returns the number of bytes actually read; 0 on EOF and error */ static int dynamicGetbuf(gdIOCtxPtr ctx, void *buf, int len) { int rlen, remain; @@ -262,21 +263,25 @@ dctx = (dpIOCtxPtr) ctx; dp = dctx->dp; + if (dp->pos < 0 || dp->pos >= dp->realSize) { + return 0; + } + remain = dp->logicalSize - dp->pos; if(remain >= len) { rlen = len; } else { if(remain <= 0) { - /* 2.0.34: EOF is incorrect. We use 0 for - * errors and EOF, just like fileGetbuf, - * which is a simple fread() wrapper. - * TBB. Original bug report: Daniel Cowgill. */ - return 0; /* NOT EOF */ + return 0; } rlen = remain; } + if (dp->pos + rlen > dp->realSize) { + rlen = dp->realSize - dp->pos; + } + memcpy(buf, (void *) ((char *)dp->data + dp->pos), rlen); dp->pos += rlen; Index: libgd2-2.1.1/src/gd_tiff.c =================================================================== --- libgd2-2.1.1.orig/src/gd_tiff.c 2016-10-18 14:16:28.629017465 +0200 +++ libgd2-2.1.1/src/gd_tiff.c 2016-10-18 14:16:28.629017465 +0200 @@ -727,6 +727,7 @@ int height = im->sy; uint32 *buffer; uint32 rgba; + int success; /* switch off colour merging on target gd image just while we write out * content - we want to preserve the alpha data until the user chooses @@ -739,18 +740,20 @@ return GD_FAILURE; } - TIFFReadRGBAImage(tif, width, height, buffer, 0); + success = TIFFReadRGBAImage(tif, width, height, buffer, 1); - for(y = 0; y < height; y++) { - for(x = 0; x < width; x++) { - /* if it doesn't already exist, allocate a new colour, - * else use existing one */ - rgba = buffer[(y * width + x)]; - a = (0xff - TIFFGetA(rgba)) / 2; - color = gdTrueColorAlpha(TIFFGetR(rgba), TIFFGetG(rgba), TIFFGetB(rgba), a); - - /* set pixel colour to this colour */ - gdImageSetPixel(im, x, height - y - 1, color); + if (success) { + for(y = 0; y < height; y++) { + for(x = 0; x < width; x++) { + /* if it doesn't already exist, allocate a new colour, + * else use existing one */ + rgba = buffer[(y * width + x)]; + a = (0xff - TIFFGetA(rgba)) / 2; + color = gdTrueColorAlpha(TIFFGetR(rgba), TIFFGetG(rgba), TIFFGetB(rgba), a); + + /* set pixel colour to this colour */ + gdImageSetPixel(im, x, height - y - 1, color); + } } } @@ -758,7 +761,7 @@ /* now reset colour merge for alpha blending routines */ gdImageAlphaBlending(im, alphaBlendingFlag); - return GD_SUCCESS; + return success; } /* gdImageCreateFromTiffCtx debian/patches/CVE-2014-9709-1.patch0000644000000000000000000000214312721574661013416 0ustar From 47eb44b2e90ca88a08dca9f9a1aa9041e9587f43 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Sat, 13 Dec 2014 08:48:18 +0100 Subject: [PATCH] Fix possible buffer read overflow detected by -fsanitize=address, thanks to Jan Bee --- src/gd_gif_in.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) Index: libgd2-2.1.0/src/gd_gif_in.c =================================================================== --- libgd2-2.1.0.orig/src/gd_gif_in.c 2016-05-26 09:27:10.848687688 -0400 +++ libgd2-2.1.0/src/gd_gif_in.c 2016-05-26 09:27:10.848687688 -0400 @@ -75,8 +75,10 @@ #define STACK_SIZE ((1<<(MAX_LWZ_BITS))*2) +#define CSD_BUF_SIZE 280 + typedef struct { - unsigned char buf[280]; + unsigned char buf[CSD_BUF_SIZE]; int curbit; int lastbit; int done; @@ -410,7 +412,12 @@ ret = 0; for (i = scd->curbit, j = 0; j < code_size; ++i, ++j) { - ret |= ((scd->buf[i / 8] & (1 << (i % 8))) != 0) << j; + if (i < CSD_BUF_SIZE * 8) { + ret |= ((scd->buf[i / 8] & (1 << (i % 8))) != 0) << j; + } else { + ret = -1; + break; + } } scd->curbit += code_size; debian/patches/CVE-2016-9317.patch0000644000000000000000000000261713055314435013253 0ustar From 6944ea10cb730d5071620439c6c2e823e6caeff1 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sat, 12 Nov 2016 15:00:31 +0100 Subject: [PATCH] Fix #340: System frozen gdImageCreate() doesn't check for oversized images and as such is prone to DoS vulnerabilities. We fix that by applying the same overflow check that is already in place for gdImageCreateTrueColor(). CVE-2016-9317 Conflicts: src/gd.c --- src/gd.c | 4 ++++ tests/CMakeLists.txt | 1 + tests/Makefile.am | 1 + tests/gdimagecreate/.gitignore | 1 + tests/gdimagecreate/CMakeLists.txt | 5 +++++ tests/gdimagecreate/Makemodule.am | 5 +++++ tests/gdimagecreate/bug00340.c | 33 +++++++++++++++++++++++++++++++++ 7 files changed, 50 insertions(+) create mode 100644 tests/gdimagecreate/.gitignore create mode 100644 tests/gdimagecreate/CMakeLists.txt create mode 100644 tests/gdimagecreate/Makemodule.am create mode 100644 tests/gdimagecreate/bug00340.c Index: libgd2-2.1.0/src/gd.c =================================================================== --- libgd2-2.1.0.orig/src/gd.c 2017-02-28 10:36:56.818973094 -0500 +++ libgd2-2.1.0/src/gd.c 2017-02-28 10:36:56.818973094 -0500 @@ -134,6 +134,10 @@ int i; gdImagePtr im; + if (overflow2(sx, sy)) { + return NULL; + } + if (overflow2(sizeof (unsigned char *), sy)) { return NULL; } debian/patches/CVE-2016-5766.patch0000644000000000000000000000165512737771732013275 0ustar Description: fix integer overflow in _gd2GetHeader() Origin: backport, https://github.com/libgd/libgd/commit/aba3db8ba159465ecec1089027a24835a6da9cc0 Origin: backport, https://github.com/libgd/libgd/commit/a6a0e7feabb2a9738086a5dc96348f233c87fa79 Bug: https://bugs.php.net/bug.php?id=72339 Index: libgd2-2.1.1/src/gd_gd2.c =================================================================== --- libgd2-2.1.1.orig/src/gd_gd2.c 2016-07-08 14:18:04.069070099 -0400 +++ libgd2-2.1.1/src/gd_gd2.c 2016-07-08 14:18:04.065070049 -0400 @@ -154,10 +154,18 @@ if (gd2_compressed (*fmt)) { nc = (*ncx) * (*ncy); + GD2_DBG (printf ("Reading %d chunk index entries\n", nc)); + if (overflow2(sizeof(t_chunk_info), nc)) { + goto fail1; + } sidx = sizeof (t_chunk_info) * nc; + if (sidx <= 0) { + goto fail1; + } + cidx = gdCalloc (sidx, 1); - if (!cidx) { + if (cidx == NULL) { goto fail1; } for (i = 0; i < nc; i++) { debian/patches/CVE-2016-6906-2.patch0000644000000000000000000000331213055314413013400 0ustar From 58b6dde319c301b0eae27d12e2a659e067d80558 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Tue, 16 Aug 2016 16:26:19 +0200 Subject: [PATCH] Fix OOB reads of the TGA decompression buffer It is possible to craft TGA files which will overflow the decompression buffer, but not the image's bitmap. Therefore we also have to check for potential decompression buffer overflows. This issue had been reported by Ibrahim El-Sayed to security@libgd.org; a modified case exposing an off-by-one error of the first patch had been provided by Konrad Beckmann. This commit is an amendment to commit fb0e0cce, so we use CVE-2016-6906 as well. --- src/gd_tga.c | 8 +++++++- tests/tga/Makemodule.am | 3 ++- tests/tga/heap_overflow.c | 16 ++++++++++++---- tests/tga/heap_overflow_1.tga | Bin 0 -> 605 bytes tests/tga/heap_overflow_2.tga | Bin 0 -> 8746 bytes 5 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 tests/tga/heap_overflow_1.tga create mode 100644 tests/tga/heap_overflow_2.tga Index: libgd2-2.1.1/src/gd_tga.c =================================================================== --- libgd2-2.1.1.orig/src/gd_tga.c 2017-02-28 10:23:52.513694994 -0500 +++ libgd2-2.1.1/src/gd_tga.c 2017-02-28 10:23:52.509694946 -0500 @@ -291,7 +291,13 @@ buffer_caret = 0; while( bitmap_caret < image_block_size ) { - + + if (buffer_caret + pixel_block_size > rle_size) { + gdFree( decompression_buffer ); + gdFree( conversion_buffer ); + return -1; + } + if ((decompression_buffer[buffer_caret] & TGA_RLE_FLAG) == TGA_RLE_FLAG) { encoded_pixels = ( ( decompression_buffer[ buffer_caret ] & ~TGA_RLE_FLAG ) + 1 ); buffer_caret++; debian/patches/gdlib-config-uses-pkgconfig.patch0000644000000000000000000000331212222240036017074 0ustar --- a/config/gdlib-config.in +++ b/config/gdlib-config.in @@ -2,14 +2,9 @@ # # Return information about the local GD library installation # -# Modeled after pdflib-config +# Modified to use pkgconfig -# installation directories -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ -bindir=@bindir@ +pkg=gdlib usage() { @@ -50,43 +45,43 @@ while test $# -gt 0; do case $1 in --libdir) - echo $libdir + pkg-config --variable=libdir ${pkg} ;; --includedir) - echo $includedir + pkg-config --variable=includedir ${pkg} ;; --version) - echo @VERSION@ + pkg-config --modversion ${pkg} ;; --majorversion) - echo @GDLIB_MAJOR@ + pkg-config --modversion ${pkg} | cut -f 1 -d . ;; --minorversion) - echo @GDLIB_MINOR@ + pkg-config --modversion ${pkg} | cut -f 2 -d . ;; --revision) - echo @GDLIB_REVISION@ + pkg-config --modversion ${pkg} | cut -f 3 -d . ;; --ldflags) - echo @LDFLAGS@ + pkg-config --libs-only-L ${pkg} ;; --libs) - echo -lgd @LIBS@ @LIBICONV@ + pkg-config --libs ${pkg} ;; --cflags|--includes) - echo -I@includedir@ + pkg-config --cflags ${pkg} ;; --features) echo @FEATURES@ ;; --all) - echo "GD library @VERSION@" - echo "includedir: $includedir" - echo "cflags: -I@includedir@" - echo "ldflags: @LDFLAGS@" - echo "libs: @LIBS@ @LIBICONV@" - echo "libdir: $libdir" - echo "features: @FEATURES@" + echo "GD library $($0 --version)@" + echo "includedir: $($0 --includedir)" + echo "cflags: $($0 --cflags)" + echo "ldflags: $($0 --ldflags)" + echo "libs: $($0 --libs)" + echo "libdir: $($0 --libdir)" + echo "features: $($0 --features)" ;; *) usage 1 1>&2 debian/patches/CVE-2016-6906-1.patch0000644000000000000000000000402113055314407013400 0ustar From fb0e0cce0b9f25389ab56604c3547351617e1415 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Tue, 16 Aug 2016 16:26:19 +0200 Subject: [PATCH] Fix OOB reads of the TGA decompression buffer It is possible to craft TGA files which will overflow the decompression buffer, but not the image's bitmap. Therefore we augment the check for the bitmap's overflow with a check for the buffer's overflow. This issue had been reported by Ibrahim El-Sayed to security@libgd.org. CVE-2016-6906 --- src/gd_tga.c | 6 ++++-- tests/tga/.gitignore | 1 + tests/tga/CMakeLists.txt | 1 + tests/tga/Makemodule.am | 2 ++ tests/tga/heap_overflow.c | 51 ++++++++++++++++++++++++++++++++++++++++++++ tests/tga/heap_overflow.tga | Bin 0 -> 605 bytes 6 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 tests/tga/heap_overflow.c create mode 100644 tests/tga/heap_overflow.tga Index: libgd2-2.1.1/src/gd_tga.c =================================================================== --- libgd2-2.1.1.orig/src/gd_tga.c 2017-02-28 10:23:46.273621175 -0500 +++ libgd2-2.1.1/src/gd_tga.c 2017-02-28 10:23:46.269621129 -0500 @@ -296,7 +296,8 @@ encoded_pixels = ( ( decompression_buffer[ buffer_caret ] & ~TGA_RLE_FLAG ) + 1 ); buffer_caret++; - if ((bitmap_caret + (encoded_pixels * pixel_block_size)) > image_block_size) { + if ((bitmap_caret + (encoded_pixels * pixel_block_size)) > image_block_size + || buffer_caret + pixel_block_size > rle_size) { gdFree( decompression_buffer ); gdFree( conversion_buffer ); return -1; @@ -312,7 +313,8 @@ encoded_pixels = decompression_buffer[ buffer_caret ] + 1; buffer_caret++; - if ((bitmap_caret + (encoded_pixels * pixel_block_size)) > image_block_size) { + if ((bitmap_caret + (encoded_pixels * pixel_block_size)) > image_block_size + || buffer_caret + (encoded_pixels * pixel_block_size) > rle_size) { gdFree( decompression_buffer ); gdFree( conversion_buffer ); return -1; debian/patches/CVE-2019-6977.patch0000644000000000000000000000277713435563307013304 0ustar Ported from php patch: From a15af81b5f0058e020eda0f109f51a3c863f5212 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sun, 30 Dec 2018 13:59:26 +0100 Subject: [PATCH] Fix #77270: imagecolormatch Out Of Bounds Write on Heap At least some of the image reading functions may return images which use color indexes greater than or equal to im->colorsTotal. We cater to this by always using a buffer size which is sufficient for `gdMaxColors` in `gdImageColorMatch()`. (cherry picked from commit 7a12dad4dd6c370835b13afae214b240082c7538) --- NEWS | 1 + ext/gd/libgd/gd_color_match.c | 4 ++-- ext/gd/tests/bug77270.phpt | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 ext/gd/tests/bug77270.phpt Index: libgd2-2.1.1/src/gd_color_match.c =================================================================== --- libgd2-2.1.1.orig/src/gd_color_match.c 2019-02-27 14:32:19.171334602 -0500 +++ libgd2-2.1.1/src/gd_color_match.c 2019-02-27 14:32:19.167334588 -0500 @@ -29,8 +29,8 @@ BGD_DECLARE(int) gdImageColorMatch (gdIm return -4; /* At least 1 color must be allocated */ } - buf = (unsigned long *)gdMalloc(sizeof(unsigned long) * 5 * im2->colorsTotal); - memset (buf, 0, sizeof(unsigned long) * 5 * im2->colorsTotal ); + buf = (unsigned long *)gdMalloc(sizeof(unsigned long) * 5 * gdMaxColors); + memset (buf, 0, sizeof(unsigned long) * 5 * gdMaxColors ); for (x=0; x < im1->sx; x++) { for( y=0; ysy; y++ ) { debian/patches/CVE-2016-10166.patch0000644000000000000000000000331613055314455013324 0ustar From 60bfb401ad5a4a8ae995dcd36372fe15c71e1a35 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sat, 6 Aug 2016 10:08:53 +0200 Subject: [PATCH] Fix potential unsigned underflow No need to decrease `u`, so we don't do it. While we're at it, we also factor out the overflow check of the loop, what improves performance and readability. This issue has been reported by Stefan Esser to security@libgd.org. --- src/gd_interpolation.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) Index: libgd2-2.1.0/src/gd_interpolation.c =================================================================== --- libgd2-2.1.0.orig/src/gd_interpolation.c 2017-02-28 10:37:14.791185700 -0500 +++ libgd2-2.1.0/src/gd_interpolation.c 2017-02-28 10:37:14.767185417 -0500 @@ -901,8 +901,13 @@ { unsigned int u = 0; LineContribType *res; - int overflow_error = 0; + size_t weights_size; + if (overflow2(windows_size, sizeof(double))) { + return NULL; + } else { + weights_size = windows_size * sizeof(double); + } res = (LineContribType *) gdMalloc(sizeof(LineContribType)); if (!res) { return NULL; @@ -919,15 +924,11 @@ return NULL; } for (u = 0 ; u < line_length ; u++) { - if (overflow2(windows_size, sizeof(double))) { - overflow_error = 1; - } else { - res->ContribRow[u].Weights = (double *) gdMalloc(windows_size * sizeof(double)); - } - if (overflow_error == 1 || res->ContribRow[u].Weights == NULL) { + res->ContribRow[u].Weights = (double *) gdMalloc(weights_size); + if (res->ContribRow[u].Weights == NULL) { unsigned int i; - u--; - for (i=0;i<=u;i++) { + + for (i=0;iContribRow[i].Weights); } gdFree(res->ContribRow); debian/patches/CVE-2017-7890.patch0000644000000000000000000000634313143322216013252 0ustar Backported of: From c613bc169802bb4b639ee2e15c61b25b80a88424 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Thu, 10 Aug 2017 18:31:29 +0200 Subject: [PATCH] Close #339: Fix unitialized memory read vulnerability in GIF reading The stack allocated color map buffers were not zeroed before usage, and so undefined palette indexes could cause information leakage. This issue has been reported by Matviy Kotoniy to security@libgd.org in . --- src/gd_gif_in.c | 3 +++ tests/Makefile.am | 1 + tests/gif/CMakeLists.txt | 1 + tests/gif/uninitialized_memory_read.c | 50 +++++++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 tests/gif/uninitialized_memory_read.c diff --git a/src/gd_gif_in.c b/src/gd_gif_in.c index 6fdada3..5be3d47 100644 --- a/src/gd_gif_in.c +++ b/src/gd_gif_in.c @@ -152,6 +152,9 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromGifCtx(gdIOCtxPtr fd) gdImagePtr im = 0; + memset(ColorMap, 0, 3 * MAXCOLORMAPSIZE); + memset(localColorMap, 0, 3 * MAXCOLORMAPSIZE); + if(!ReadOK(fd, buf, 6)) { return 0; } diff --git a/tests/Makefile.am b/tests/Makefile.am index 65c1029..76d3860 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -27,6 +27,7 @@ check_PROGRAMS = \ gdimagecolortransparent/gdimagecolortransparent \ gif/bug00005_2 \ gif/gif_null \ + gif/uninitialized_memory_read \ gif/bug00181 \ gif/bug00227 \ bmp/bmp_null diff --git a/tests/gif/CMakeLists.txt b/tests/gif/CMakeLists.txt index a155559..830c766 100644 --- a/tests/gif/CMakeLists.txt +++ b/tests/gif/CMakeLists.txt @@ -9,6 +9,7 @@ SET(TESTS_FILES bug00066 bug00181 bug00227 + uninititalized_memory_read ) FOREACH(test_name ${TESTS_FILES}) diff --git a/tests/gif/uninitialized_memory_read.c b/tests/gif/uninitialized_memory_read.c new file mode 100644 index 0000000..b9cd36a --- /dev/null +++ b/tests/gif/uninitialized_memory_read.c @@ -0,0 +1,50 @@ +/** + * Test for uninitialized color map entries + * + * We're reading a crafted GIF which consists of 16x16 color blocks and which + * has only two palette entries in the global color map, but uses other palette + * indexes as well. We verify whether all undefined palette indexes produce the + * color black. + * + * See also + * which had been sent to security@libgd.org. + */ + + +#include "gd.h" +#include "gdtest.h" + + +int main() +{ + gdImagePtr im; + FILE *fp; + int i, j, col; + char path[1024]; + + sprintf(path, "%s/gif/unitialized_memory_read.gif", GDTEST_TOP_DIR); + fp = fopen(path, "rb"); + + if (!fp) { + printf("cannot open <%s>\n", path); + return -1; + } + + gdTestAssert(fp != NULL); + im = gdImageCreateFromGif(fp); + gdTestAssert(im != NULL); + fclose(fp); + + for (i = 0; i < gdImageSX(im); i += 16) { + for (j = 0; j < gdImageSY(im); j += 16) { + if (gdImageGetPixel(im, i, j) >= 2) { + col = gdImageGetTrueColorPixel(im, i, j); + gdTestAssert(col == 0); + } + } + } + + gdImageDestroy(im); + + return 0; +} -- 2.7.4 debian/patches/CVE-2016-7568.patch0000644000000000000000000000164412775461376013277 0ustar Description: fix denial of service and possible code execution Origin: based on http://git.php.net/?p=php-src.git;a=commit;h=46df0642618eabc5b5b7df490d1ae23bda00a745 Bug: https://github.com/libgd/libgd/issues/308 Index: libgd2-2.1.1/src/gd_webp.c =================================================================== --- libgd2-2.1.1.orig/src/gd_webp.c 2015-01-13 22:09:04.000000000 -0500 +++ libgd2-2.1.1/src/gd_webp.c 2016-10-06 10:40:53.394331583 -0400 @@ -179,6 +179,15 @@ /* Conversion to Y,U,V buffer */ yuv_width = (width + 1) >> 1; yuv_height = (height + 1) >> 1; + + if (overflow2(width, height)) { + return; + } + /* simplification possible, because WebP must not be larger than 16384**2 */ + if (overflow2(width * height, 2 * sizeof(unsigned char))) { + return; + } + yuv_nbytes = width * height + 2 * yuv_width * yuv_height; if ((Y = (unsigned char *)gdCalloc(yuv_nbytes, sizeof(unsigned char))) == NULL) { debian/libgd2-xpm-dev.postinst0000644000000000000000000000027412222240036013510 0ustar #!/bin/sh set -e DOCDIR=/usr/share/doc/libgd2-xpm-dev DOCLINK=libgd-dev if [ -d $DOCDIR ] && [ ! -L $DOCDIR ]; then rmdir $DOCDIR ln -s $DOCLINK $DOCDIR fi #DEBHELPER# exit 0 debian/libgd-dev.examples0000644000000000000000000000013212222240036012550 0ustar src/demoin.png src/gdtest.c src/gdtestft.c src/gddemo.c src/gd2time.c src/testac.c test/* debian/libgd-tools.manpages0000644000000000000000000000002512222240036013110 0ustar debian/libgd-tools.1 debian/README.source0000644000000000000000000000376312222240036011347 0ustar Building this package for Debian -------------------------------- This source package uses quilt to apply and remove its patches. Please refer to /usr/share/doc/quilt/README.source for information about how to use quilt for source packages. Developing this package for Debian ---------------------------------- The source of this package is developed using git and the helper tool git-buildpackage, with all official releases tagged and signed and binary diffs of tarballs stored using pristine-tar. This is documented below /usr/share/doc/git-buildpackage/manual-html/ . A custom build target shows current upstream and packaging versions: debian/rules print-version Current upstream tarball can be prepared using this other build target: debian/rules get-orig-source To switch to newer upstream source, first add a dummy changelog entry and comment out DEB_UPSTREAM_TARBALL_MD5 before getting the source: dch -v ${new_upstream_version}-1 "Dummy changelog entry" sed -i -e 's/^\(DEB_UPSTREAM_TARBALL_MD5\b\)/#\1/' debian/rules debian/rules get-orig-source Store new md5sum to help ensure identical source is received later. Setting DEB_MAINTAINER_MODE=1 enables additional build routines helpful during development of the package, but unfit for normal builds. This typically includes the CDBS feature of auto-updating debian/control with CDBS-related build-dependencies, which is forbidden by Debian Policy as build environment must not change during automated builds. Maintaining packaging build routines ------------------------------------ This source package wraps debhelper commands and other tedious parts of the build routines using the CDBS framework. Please refer to the actual makefile snippets included from debian/rules for details on their purpose and ways to override defaults. Additionally, makefile snippets included from below /usr/share/cdbs may also be documented in /usr/share/doc/cdbs/cdbs-doc.pdf.gz . -- Jonas Smedegaard Thu, 26 Feb 2009 21:28:29 +0100 debian/compat0000644000000000000000000000000212222240036010355 0ustar 9 debian/libgd-tools.links0000644000000000000000000000117712222240036012446 0ustar /usr/share/man/man1/libgd-tools.1.gz /usr/share/man/man1/annotate.1.gz /usr/share/man/man1/libgd-tools.1.gz /usr/share/man/man1/bdftogd.1.gz /usr/share/man/man1/libgd-tools.1.gz /usr/share/man/man1/pngtogd.1.gz /usr/share/man/man1/libgd-tools.1.gz /usr/share/man/man1/pngtogd2.1.gz /usr/share/man/man1/libgd-tools.1.gz /usr/share/man/man1/gdtopng.1.gz /usr/share/man/man1/libgd-tools.1.gz /usr/share/man/man1/gd2topng.1.gz /usr/share/man/man1/libgd-tools.1.gz /usr/share/man/man1/gd2copypal.1.gz /usr/share/man/man1/libgd-tools.1.gz /usr/share/man/man1/gdparttopng.1.gz /usr/share/man/man1/libgd-tools.1.gz /usr/share/man/man1/webpng.1.gz debian/copyright0000644000000000000000000002404112222240036011113 0ustar Format: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?rev=174 Upstream-Name: GD Upstream-Contact: Pierre-Alain Joye Source: http://www.libgd.org/releases/ Files-Excluded: VMS/* test/* Files: * Copyright: 1991-2002, Thomas G. Lane 1994-2002, Cold Spring Harbor Laboratory 1996-2002, Thomas Boutell (Boutell.Com, Inc.) 1999-2002, Greg Roelofs 1999-2002, John Ellson 1999-2002, Philip Warner 2000-2002, Maurice Szmurlo 2000-2002, Johan Van den Brande 2000-2002, Doug Becker 2000-2007 Pierre-Alain Joye License: GD Files: */Makefile.in Copyright: 1994-2006, Free Software Foundation, Inc. License: GAP~Makefile.in Files: depcomp ltmain.sh missing Copyright: 1996-2005, Free Software Foundation, Inc License: GPL-2+ with Autoconf exception As a special exception to the GNU General Public License, if you distribute this file as part of a program that contains a configuration script generated by Autoconf, you may include it under the same distribution terms that you use for the rest of that program. Files: src/strlcpy.c Copyright: 1998, Todd C. Miller License: BSD-3-clause Files: configure Copyright: 1992-1996, 1998-2006 License: GAP~configure Files: install-sh Copyright: 1991, the Massachusetts Institute of Technology License: MIT Files: src/gd_wbmp.c Copyright: 2000, Maurice Szmurlo ????, Johan Van den Brande License: HPND Files: src/gd_gif_out.c Copyright: 1989, Jef Poskanzer License: HPND Files: src/gd_nnquant.c Copyright: 1994, Anthony Dekker 2004-2007, Stuart Coyle 2013, Pierre A. Joye License: XFIG Files: src/webpimg.c src/webpimg.h Copyright: 2010, Google Inc. All rights reserved. License: WEBP Files: cmake/modules/CheckDIRSymbolExists.cmake cmake/modules/CheckPrototypeExists.cmake cmake/modules/CMakeParseArguments.cmake cmake/modules/FindFontConfig.cmake cmake/modules/FindFreetype.cmake cmake/modules/FindJPEG.cmake cmake/modules/FindPackageHandleStandardArgs.cmake cmake/modules/FindPNG.cmake cmake/modules/FindVPX.cmake cmake/modules/FindXPM.cmake Copyright: 2002-2013, Kitware, Inc., Insight Consortium 2010 Alexander Neundorf 2013 Pierre A. Joye 2006,2007 Laurent Montel License: BSD-3-clause Files: cmake/modules/FindPTHREAD.cmake Copyright: 2005 - 2013 by INRIA License: GPL-2+ Files: cmake/modules/TestForHighBitCharacters.cmake cmake/modules/TestForHighBitCharacters.c cmake/modules/TestForStandardHeaderwait.cmake Copyright: 2006 Alan W. Irwin License: GPL-2+ Files: debian/* Copyright: 2001, Ivo Timmermans 2002-2010, Jonas Smedegaard 2013, Ondřej Surý License: GPL-2+ License: GPL-2+ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. Comment: On Debian systems the 'GNU General Public License' version 2 is located in '/usr/share/common-licenses/GPL-2'. License: GAP~Makefile.in This Makefile.in is free software; the Free Software Foundation gives unlimited permission to copy and/or distribute it, with or without modifications, as long as this notice is preserved. License: GAP~configure This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. License: GD Permission has been granted to copy, distribute and modify gd in any context without fee, including a commercial application, provided that this notice is present in user-accessible supporting documentation. . This does not affect your ownership of the derived work itself, and the intent is to assure proper credit for the authors of gd, not to interfere with your productive use of gd. If you have questions, ask. "Derived works" includes all programs that utilize the library. Credit must be given in user-accessible documentation. . This software is provided "AS IS." The copyright holders disclaim all warranties, either express or implied, including but not limited to implied warranties of merchantability and fitness for a particular purpose, with respect to this code and accompanying documentation. License: HPND Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. This software is provided "as is" without express or implied warranty. License: BSD-3-clause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. . THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. License: MIT Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of M.I.T. not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. M.I.T. makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. License: XFIG Any party obtaining a copy of these files from the author, directly or indirectly, is granted, free of charge, a full and unrestricted irrevocable, world-wide, paid up, royalty-free, nonexclusive right and license to deal in this software and documentation files (the "Software"), including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons who receive copies from any such party to do so, with the only requirement being that this copyright notice remain intact. License: WEBP Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: . * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. . * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. . * Neither the name of Google nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. . THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. . Additional IP Rights Grant (Patents) . “This implementation” means the copyrightable works distributed by Google as part of the WebM Project. . Google hereby grants to you a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, transfer, and otherwise run, modify and propagate the contents of this implementation of VP8, where such license applies only to those patent claims, both currently owned by Google and acquired in the future, licensable by Google that are necessarily infringed by this implementation of VP8. This grant does not include claims that would be infringed only as a consequence of further modification of this implementation. If you or your agent or exclusive licensee institute or order or agree to the institution of patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that this implementation of VP8 or any code incorporated within this implementation of VP8 constitutes direct or contributory patent infringement, or inducement of patent infringement, then any patent rights granted to you under this License for this implementation of VP8 shall terminate as of the date such litigation is filed. debian/libgd-tools.install0000644000000000000000000000031412222240036012764 0ustar usr/bin/gd2togif usr/bin/gd2copypal usr/bin/pngtogd2 usr/bin/gdcmpgif usr/bin/giftogd2 usr/bin/annotate usr/bin/pngtogd usr/bin/gdtopng usr/bin/webpng usr/bin/gdparttopng usr/bin/gd2topng usr/bin/bdftogd debian/libgd3.dirs0000644000000000000000000000001012222240036011175 0ustar usr/lib debian/libgd-dev.dirs0000644000000000000000000000002412222240036011673 0ustar usr/lib usr/include debian/libgd3.lintian-overrides0000644000000000000000000000011112222240036013674 0ustar libgd3: embedded-library usr/lib/x86_64-linux-gnu/libgd.so.3.0.0: libgd2 debian/source/0000755000000000000000000000000013153345556010500 5ustar debian/source/include-binaries0000644000000000000000000000007613153345556013643 0ustar tests/gif/unitialized_memory_read.gif tests/png/bug00381_2.gd debian/source/format0000644000000000000000000000001412222240036011665 0ustar 3.0 (quilt) debian/libgd3.install0000644000000000000000000000002412222240036011707 0ustar usr/lib/*/lib*.so.* debian/libgd-tools.10000644000000000000000000000165612222240036011470 0ustar .TH LIBGD-TOOLS 1 "13 July 2002" .SH NAME libgd-tools \- programs to convert between gd and other graphics formats .SH SYNOPSIS .B libgd-tools .RI [ options ] " files" ... .br .B bar .RI [ options ] " files" ... .SH DESCRIPTION This manual page documents briefly the .B annotate , .B bdftogd , .B pngtogd , .B pngtogd2 , .B gdtopng , .B gd2topng , .B gd2copypal , .B gdparttopng and .B webpng commands, which are all distributed as part of the gd library. This manual page was written for the Debian distribution because the original program does not have a manual page. .PP .B libgd-tools are programs that convert between gd and other graphics formats. .SH OPTIONS These programs usually takes two options: input file and output file. If in doubt, simply run the program with no options for a tiny help. .SH AUTHOR This manual page was written by Jonas Smedegaard , for the Debian GNU/Linux system (but may be used by others). debian/libgd-dev.install0000644000000000000000000000013412222240036012402 0ustar usr/bin/gdlib-config usr/include/* usr/lib/*/lib*.a usr/lib/*/lib*.so usr/lib/*/pkgconfig/* debian/libgd2-xpm-dev.lintian-overrides0000644000000000000000000000013012222240036015252 0ustar libgd2-xpm-dev: virtual-package-depends-without-real-package-depends depends: libgd-dev debian/libgd2-noxpm-dev.postinst0000644000000000000000000000027612222240036014047 0ustar #!/bin/sh set -e DOCDIR=/usr/share/doc/libgd2-noxpm-dev DOCLINK=libgd-dev if [ -d $DOCDIR ] && [ ! -L $DOCDIR ]; then rmdir $DOCDIR ln -s $DOCLINK $DOCDIR fi #DEBHELPER# exit 0 debian/gdlib-config.10000644000000000000000000000361212222240036011567 0ustar .TH GD 1 .SH NAME gdlib-config - script to get information about the installed version of GD .SH SYNOPSIS .B gdlib-config [\-\-prefix\fI[=DIR]\fP] [\-\-exec\-prefix\fI[=DIR]\fP] [\-\-version] [\-\-libs] [\-\-cflags] .SH DESCRIPTION \fIgdlib-config\fP is a tool that is used to configure to determine the compiler and linker flags that should be used to compile and link programs that use the \fIGD\fP library. It is also used internally to the .m4 macros for GNU autoconf that are included with the \fIGD\fP library. . .SH OPTIONS \fIgdlib-config\fP accepts the following options (and more - run \fIgdlib-config\fP with no options for the rest): .TP 8 .B \-\-version Print the currently installed version of the \fIGD\fP library on the standard output. .TP 8 .B \-\-libs Print the linker flags that are necessary to link a \fIGD\fP program. .TP 8 .B \-\-cflags Print the compiler flags that are necessary to compile a \fIGD\fP program. .TP 8 .B \-\-prefix=PREFIX If specified, use PREFIX instead of the installation prefix that \fIGD\fP was built with when computing the output for the \-\-cflags and \-\-libs options. This option is also used for the exec prefix if \-\-exec\-prefix was not specified. This option must be specified before any \-\-libs or \-\-cflags options. .TP 8 .B \-\-exec\-prefix=PREFIX If specified, use PREFIX instead of the installation exec prefix that \fIGD\fP was built with when computing the output for the \-\-cflags and \-\-libs options. This option must be specified before any \-\-libs or \-\-cflags options. .SH COPYRIGHT Copyright \(co 1998 Owen Taylor Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. Modified for GD by Jonas Smedegaard debian/libgd-dev.manpages0000644000000000000000000000002612222240036012527 0ustar debian/gdlib-config.1 debian/changelog0000644000000000000000000014651713435564037011070 0ustar libgd2 (2.1.0-3ubuntu0.11) trusty-security; urgency=medium * SECURITY UPDATE: buffer overflow in gdImageColorMatch - debian/patches/CVE-2019-6977.patch: use gdMaxColors in src/gd_color_match.c. - CVE-2019-6977 * SECURITY UPDATE: double-free in gdImage*Ptr() functions - debian/patches/CVE-2019-6978.patch: properly handle failure in src/gd_gif_out.c, src/gd_jpeg.c, src/gd_wbmp.c, add test to tests/jpeg/CMakeLists.txt, tests/jpeg/jpeg_ptr_double_free.c. - CVE-2019-6978 -- Marc Deslauriers Wed, 27 Feb 2019 14:42:23 -0500 libgd2 (2.1.0-3ubuntu0.10) trusty-security; urgency=medium * SECURITY UPDATE: Double free - debian/patches/CVE-2018-1000222.patch: fix in src/gd_bmp.c. - CVE-2018-1000222 * SECURITY UPDATE: Infinite loop - debian/patches/CVE-2018-5711.patch: fix in src/gd_gif_in.c. - CVE-2018-5711 -- Leonidas S. Barbosa Thu, 23 Aug 2018 10:51:28 -0300 libgd2 (2.1.0-3ubuntu0.8) trusty-security; urgency=medium * SECURITY UPDATE: Double-free memory - debian/patches/CVE-2017-6362.patch: introduces a static helper to check failure or success in src/gd_png.c also adds tests in tests/png/CMakeLists.txt, tests/Makemodule.am, tests/png/bug00381_1.c, tests/png/bug00381_2.c. - CVE-2017-6362 -- Leonidas S. Barbosa Mon, 04 Sep 2017 18:55:20 -0300 libgd2 (2.1.0-3ubuntu0.7) trusty-security; urgency=medium * SECURITY UPDATE: memory read vulnerability in GIF - debian/patches/CVE-2017-7890.patch: zeroing buffers to avoid information leak and adding test in src/gd_gif_in.c, tests/gif/CMakeLists.txt, tests/MakeModule.am, tests/gif/uninitialized_memory_read.c, tests/gif/unitialized_memory_read.gif. - CVE-2017-7890 -- Leonidas S. Barbosa Thu, 10 Aug 2017 19:17:28 -0300 libgd2 (2.1.0-3ubuntu0.6) trusty-security; urgency=medium * SECURITY UPDATE: potential unsigned underflow - debian/patches/CVE-2016-10166.patch: refactor loop in src/gd_interpolation.c. - CVE-2016-10166 * SECURITY UPDATE: DoS vulnerability in gdImageCreateFromGd2Ctx() - debian/patches/CVE-2016-10167.patch: properly fail in src/gd_gd2.c. - CVE-2016-10167 * SECURITY UPDATE: signed integer overflow in gd_io.c - debian/patches/CVE-2016-10168.patch: check counts in src/gd_gd2.c. - CVE-2016-10168 * SECURITY UPDATE: OOB reads of the TGA decompression buffer - debian/patches/CVE-2016-6906-pre1.patch: fix coverty warning in src/gd_tga.c. - debian/patches/CVE-2016-6906-pre2.patch: fix TGA RLE decoding in src/gd_tga.c. - debian/patches/CVE-2016-6906-1.patch: check for overflow in src/gd_tga.c. - debian/patches/CVE-2016-6906-2.patch: add another overflow check in src/gd_tga.c. - CVE-2016-6906 * SECURITY UPDATE: double-free in gdImageWebPtr() - debian/patches/CVE-2016-6912.patch: add helper function to indicate failure in src/gd_webp.c. - CVE-2016-6912 * SECURITY UPDATE: DoS via oversized image - debian/patches/CVE-2016-9317.patch: check for oversized images in src/gd.c. - CVE-2016-9317 * SECURITY UPDATE: DoS via stack consumption - debian/patches/CVE-2016-9933.patch: check for invalid colors in src/gd.c. - CVE-2016-9933 -- Marc Deslauriers Tue, 28 Feb 2017 10:37:45 -0500 libgd2 (2.1.0-3ubuntu0.5) trusty-security; urgency=medium * SECURITY UPDATE: denial of service via invalid read in gdImageCreateFromTiffPtr() - debian/patches/CVE-2016-6911.patch: check out of bounds reads in src/gd_io_dp.c, check return code in src/gd_tiff.c. - CVE-2016-6911 * SECURITY UPDATE: denial of service and possible code execution via integer overflow in gdImageWebpCtx - debian/patches/CVE-2015-7568.patch: check for overflow in src/gd_webp.c. - CVE-2016-7568 * SECURITY UPDATE: stack buffer overflow in dynamicGetbuf - debian/patches/CVE-2016-8670.patch: avoid potentially dangerous signed to unsigned conversion in src/gd_io_dp.c. - CVE-2016-8670 -- Marc Deslauriers Tue, 18 Oct 2016 14:18:07 +0200 libgd2 (2.1.0-3ubuntu0.3) trusty-security; urgency=medium * SECURITY UPDATE: out of bounds read in TGA file parsing - debian/patches/CVE-2016-6132.patch: properly validate image data in src/gd_tga.c. - CVE-2016-6132 * SECURITY UPDATE: OOB or OOM in gdImageScale - debian/patches/CVE-2016-6207.patch: check for overflows, use floats, and check return codes in src/gd.c, src/gd_interpolation.c. - CVE-2016-6207 * SECURITY UPDATE: out-of-bounds read issue with unsupported TGA bpp/alphabit combinations - debian/patches/CVE-2016-6214.patch: improve checks in src/gd_tga.c. - CVE-2016-6214 -- Marc Deslauriers Tue, 09 Aug 2016 09:51:31 -0400 libgd2 (2.1.0-3ubuntu0.2) trusty-security; urgency=medium * SECURITY UPDATE: out of bounds read in gdImageScaleTwoPass - debian/patches/CVE-2013-7456.patch: properly handle window size in src/gd_interpolation.c. - CVE-2013-7456 * SECURITY UPDATE: stack overflow with large names - debian/patches/CVE-2016-5116.patch: properly handle names in src/gd_xbm.c. - CVE-2016-5116 * SECURITY UPDATE: integer overflow in _gd2GetHeader() - debian/patches/CVE-2016-5766.patch: check for overflow in src/gd_gd2.c. - CVE-2016-5766 * SECURITY UPDATE: denial of service via invalid color index - debian/patches/CVE-2016-6128.patch: check color index in src/gd_crop.c, added test to tests/CMakeLists.txt, tests/Makefile.am, tests/gdimagecrop/php_bug_72494.c. - CVE-2016-6128 * SECURITY UPDATE: out of bounds read of masks array - debian/patches/CVE-2016-6161.patch: properly handle EOF marker in src/gd_gif_out.c. - CVE-2016-6161 -- Marc Deslauriers Fri, 08 Jul 2016 14:41:51 -0400 libgd2 (2.1.0-3ubuntu0.1) trusty-security; urgency=medium * SECURITY UPDATE: denial of service via crafted color table in XPM file - debian/patches/CVE-2014-2497.patch: avoid null-pointer dereference in src/gdxpm.c. - CVE-2014-2497 * SECURITY UPDATE: denial of service via crafted GIF image - debian/patches/CVE-2014-9709-1.patch: fix buffer read overflow in src/gd_gif_in.c. - debian/patches/CVE-2014-9709-2.patch: move overflow test outside the loop in src/gd_gif_in.c. - CVE-2014-9709 * SECURITY UPDATE: denial of service via crafted imagefilltoborder call - debian/patches/CVE-2015-8874.patch: add limits to src/gd.c. - CVE-2015-8874 * SECURITY UPDATE: denial of service via memleak in gdImageScaleTwoPass - debian/patches/CVE-2015-8877.patch: use gdImageDestroy in src/gd_interpolation.c. - CVE-2015-8877 * SECURITY UPDATE: denial of service and possible code execution via crafted compressed gd2 data - debian/patches/CVE-2016-3074.patch: perform range checking in src/gd_gd2.c. - CVE-2016-3074 -- Marc Deslauriers Thu, 26 May 2016 09:29:04 -0400 libgd2 (2.1.0-3) unstable; urgency=low * Enable subdir-objects in AC_INIT_AUTOMAKE (Closes: #724841) -- Ondřej Surý Mon, 30 Sep 2013 11:10:16 +0200 libgd2 (2.1.0-2) unstable; urgency=low * Properly quote GD_EXTRA_VERSIOn and GD_VERSION_STRING (Courtesy of Marc Deslauriers) (Closes: #714363) -- Ondřej Surý Fri, 28 Jun 2013 15:44:28 +0200 libgd2 (2.1.0-1) unstable; urgency=low * New upstream version 2.1.0 * Remove patches merged upstream and pull a fix for incorrect compiled-in version -- Ondřej Surý Thu, 27 Jun 2013 10:02:00 +0200 libgd2 (2.1.0~rc2-2) unstable; urgency=low * Pull new upstream tests and fixes (fixes the FTBFS on 32-bit archs) -- Ondřej Surý Mon, 10 Jun 2013 09:46:52 +0200 libgd2 (2.1.0~rc2-1) unstable; urgency=low * New upstream version 2.1.0~rc2 * font-pattern-pointer-deref.patch: Remove, merged upstream * Add new gdImageClone symbol in upstream libgd3 library -- Ondřej Surý Fri, 07 Jun 2013 13:30:36 +0200 libgd2 (2.1.0~rc1-2) unstable; urgency=low [ Colin Watson ] * Add missing pointer dereference in font_pattern (closes: #709050). [ Ondřej Surý ] * "I will test my changes with piuparts" release (Closes: #708111) -- Ondřej Surý Sat, 25 May 2013 19:43:22 +0200 libgd2 (2.1.0~rc1-1) unstable; urgency=low * Imported Upstream version 2.1.0~rc1 * Remove patches merged in upstream -- Ondřej Surý Fri, 24 May 2013 09:09:47 +0200 libgd2 (2.1.0~alpha1-6) unstable; urgency=low * Fix libgd2-dev -> libgd-dev in transitional packages (Closes: #708111) -- Ondřej Surý Thu, 23 May 2013 13:24:57 +0200 libgd2 (2.1.0~alpha1-5) unstable; urgency=low * Drop chrpath, it's not needed when we switched to libtiff-dev and it was broken anyway. -- Ondřej Surý Wed, 22 May 2013 10:28:27 +0200 libgd2 (2.1.0~alpha1-4) unstable; urgency=low * Build-Depend and Depend on libtiff-dev to make binNMUs easier * Fix libgd-dev dependency from libpng12-dev to libpng-dev * Don't ignore errors in postinst scripts * Fix debhelper-but-no-misc-depends in transitional packages * Silence invalid warning about virtual package depends on libgd-dev * Add missing Files: * to debian/copyright main License block * Explicitly call --with-tiff=/usr to catch tiff 3.x without pkg-config * Enable full hardening build -- Ondřej Surý Tue, 21 May 2013 17:47:54 +0200 libgd2 (2.1.0~alpha1-3) unstable; urgency=low * Build-depend on libtiff5-alt-dev to easy the transition * Pull some upstream fixes (Closes: #709074, #709074) * Add pkg-config support for tiff-4 (and others) to allow compilation against libtiff5-alt-dev (pull from upstream) * libgd-dev now depends on libtiff5-alt-dev | libtiff5-dev | libtiff-dev * Remove RPATH from binaries, it's not needed -- Ondřej Surý Fri, 17 May 2013 15:32:27 +0200 libgd2 (2.1.0~alpha1-2) unstable; urgency=low * Upload to unstable * Build-depend on libtiff5-dev | libtiff-dev to allow easier backports * Remove libjpeg skip test patch, add HAVE_CONFIG_H patch (Closes: #708413) * Yet another rename when uploading to unstable: + development library package to libgd-dev + shared library package to libgd3 -- Ondřej Surý Wed, 15 May 2013 13:42:49 +0200 libgd2 (2.1.0~alpha1-1) experimental; urgency=low * Update copyright with correct cmake module authors * Imported Upstream version 2.1.0~alpha1 * Update debian/watch to bitbucket.org * Add docdir symlinks in postinst for transitional packages when upgrading (Closes: #708111) -- Ondřej Surý Mon, 13 May 2013 16:57:19 +0200 libgd2 (2.1.0~alpha~8+ecc535-2) experimental; urgency=low * Build-Depend on libpng-dev (Closes: #662401) -- Ondřej Surý Tue, 07 May 2013 12:09:12 +0200 libgd2 (2.1.0~alpha~8+ecc535-1) experimental; urgency=low * Imported Upstream version 2.1.0~alpha~8+ecc535 * Imported Upstream version 2.1.0~alpha~7+292b0a * Imported Upstream version 2.1.0~alpha~6+bc7015 * Remove Breaks: php5-common, since it also clashes with PHP 5.4 * Introduce libgd2-dbg package with debug symbols -- Ondřej Surý Sun, 05 May 2013 10:42:20 +0200 libgd2 (2.1.0~alpha~5+9ca645-1) experimental; urgency=low * Imported Upstream version 2.1.0~alpha~5+9ca645 + This build changes the double->int conversion in clip_1d hopefully allowing the tests to pass correctly -- Ondřej Surý Sat, 27 Apr 2013 09:15:08 +0200 libgd2 (2.1.0~alpha~4+cf9d7f-1) experimental; urgency=low * Imported Upstream version 2.1.0~alpha~3 * Imported Upstream version 2.1.0~alpha~4+cf9d7f * Disable jpeg_read test which is broken with libjpeg8 * Add couple of new symbols and remove gdImageAntialias, that didn't make it to 2.1.0; add Breaks: php5 (<< 5.5.0~beta4) -- Ondřej Surý Thu, 25 Apr 2013 12:17:06 +0200 libgd2 (2.1.0~alpha~2-1) experimental; urgency=low * Imported Upstream version 2.1.0~alpha~2 * Update debian/libgd2-3.symbols with new functions -- Ondřej Surý Thu, 18 Apr 2013 09:35:28 +0200 libgd2 (2.1.0~alpha~1-2) experimental; urgency=low * Introduce transitional packages for libgd2-{noxpm,xpm}-dev * Don't install separate docs for transitional packages * Fix some formatting errors in gdlib-config.1 manpage * Fix the xmp->xpm typo -- Ondřej Surý Tue, 16 Apr 2013 08:58:45 +0200 libgd2 (2.1.0~alpha~1-1) experimental; urgency=low * Imported Upstream version 2.1.0~alpha~1 (upstream 2.1.0-alpha git snapshot) * Update uploaders to include me and remove Jonas * Update gbp.conf for experimental * Switch the build system to debhelper * Drop gnulib dependency (I have updated config.rpath upstream) (Closes: #396172) * Get rid of xpm vs noxpm library dichotomy (Closes: #443654, #376098) + Rename libgd2-{xpm,noxpm} to libgd2-3 to match bumped SONAME + Rename libgd2-{xpm,noxpm}-dev to libgd2-dev * Update debian/copyright; add license for gd_nnquant.c and gd_wepimp.* * Override dh_install to add --fail-missing to catch all new files * Remove obsolete patches from 2.0.x series, all have been merged upstream * Add autoreconf to dh invocation to generate configure * Add VPX and TIFF support to GD library * Update libgd2-3.symbols for latest git upstream version (Closes: #661543) * Install pkgconfig files * Patch gdlib-config to use pkg-config internally (Closes: #672953) -- Ondřej Surý Sun, 14 Apr 2013 11:12:25 +0200 libgd2 (2.0.36~rc1~dfsg-6.1) unstable; urgency=low * Non-maintainer upload. * Support multi-arch: (closes: #652496) - Mark libgd2-xpm, libgd2-noxpm, libgd2-xpm-dev and libgd2-noxpm-dev as same. - Adjust d-shlibs and dh-buildinfo build-dependency. * Drop .la files. -- Bastian Blank Sun, 13 May 2012 09:16:37 +0000 libgd2 (2.0.36~rc1~dfsg-6) unstable; urgency=low * Acknowledge NMU. Closes: bug#619537, #621612. Thanks to Luk Claes. * Rewrite copyright file using draft 174 of DEP-5 format. * Add patch 0003 to fix support large images. Closes: bug#595368. Thanks to Teodor Milkov. * Add patch 0004 to fix printf string formatting. Closes: bug#643422. Thanks to Didier Raboud and Thorsten Glaser. * Bump Standards-Version to 3.9.2. * Bump debhelper compatibility level to 7. * Update package relations: + Tighten build-dependency on cdbs: Needed to support debhelper 7. + Relax build-depend unversioned on debhelper and devscripts: Needed versions satisfied even in oldstable. -- Jonas Smedegaard Sat, 15 Oct 2011 22:23:42 +0200 libgd2 (2.0.36~rc1~dfsg-5.1) unstable; urgency=low * Non-maintainer upload. * Remove references to other libraries from dependency_libs field Closes: #619537,#621612. -- Luk Claes Mon, 30 May 2011 07:51:27 +0200 libgd2 (2.0.36~rc1~dfsg-5) unstable; urgency=low * Workaround CDBS not honoring per-flavor configure flags yet. Closes: bug#595709. Thanks to brian m. carlson. * Ease building with git-buildpackage: + Git-ignore quilt .pc dir. + Add dpkg source local-options. * Update copyright-check suppression: + Fix add ./ prefix. + Suppress demo/test graphics. + Avoid suppressing the whole debian subdir. -- Jonas Smedegaard Sun, 17 Oct 2010 15:11:45 +0200 libgd2 (2.0.36~rc1~dfsg-4) unstable; urgency=low * Acknowledge NMUs. Thanks to Giuseppe Iuculano and Robert Lemmen. * Drop local CDBS snippets: All included in main cdbs package now. As local snippets conflicted with recent releases of the cdbs package this closes: bug#564374. Thanks to Lucas Nussbaum and Philipp Kern. Tighten build-dependency on cdbs. * Use dpkg source format "3.0 (quilt)". Drop patchsys-quilt.mk and related dependencies. * Packaging moved to Git: + Update Vcs-* stanzas. + Add git-buildpackage config enabling pristine-tar and signed tags. * Add README.source documenting use of CDBS and git-buildpackage, and drop README.cdbs-tweaks. Drop cdbs comments in debian/rules. * Add DEP3 hints ot patch. * Update packaging hall of shame in TODO. * Rewrite debian/copyright using draft DEP5 format rev. 135. * Preserve (not clean) upstream-shipped tempfile during build. * Depend on ${misc:Depends}. Thanks to lintian. * Bump up standards-version to 3.9.1. * Use $(filter ...) instead of $(findstring ...) to extract space- separated options from DEB_BUILD_OPTIONS in debian/rules. * Build-depend unversioned on d-shlibs (needed version satisfied in oldstable). -- Jonas Smedegaard Sun, 05 Sep 2010 14:36:52 +0200 libgd2 (2.0.36~rc1~dfsg-3.2) unstable; urgency=low * Non-maintainer upload. * Fixed libjpeg dependency (Closes: #569682) -- Robert Lemmen Tue, 23 Mar 2010 17:06:39 +0000 libgd2 (2.0.36~rc1~dfsg-3.1) unstable; urgency=high * Non-maintainer upload by the Security Team. * Fixed CVE-2009-3546: possible buffer overflow or buffer over-read attacks via crafted files (Closes: #552534) -- Giuseppe Iuculano Mon, 09 Nov 2009 21:19:11 +0100 libgd2 (2.0.36~rc1~dfsg-3) unstable; urgency=medium * Drop bogus "-Wl,--disable-rpath" ld flags. Closes: bug#478534, #476018, thanks to Kumar Appaiah. * Install (cleaned copy of) index.html as both README and README.html. * Build-depend on html2text (pulled in by debhelper too, but also used explicitly so we must depend on it ourselves according to Policy). * Update local cdbs snippets: + Add and use local autotools.mk extended to support multiple build flavors (instead of custom-invoked configure + make). As extra bonus this fixes support for cross-compilation (thanks to Kumar Appaiah for pointing it out in bug#476018). + Add local autotools-vars.mk, makefile.mk and makefile-vars.mk needed by local autotools.mk above. + Strip non-printable characters in copyright-check.mk. + Relaxed copyright-check.mk to only warn by default. + Update dependency cleanup to strip cdbs 0.4.27 (not 0.4.27-1). * Update debian/copyright-hints. * Bump debhelper compatibility level to 6. * Semi-auto-update debian/control to update build-dependencies: DEB_AUTO_UPDATE_DEBIAN_CONTROL=yes fakeroot debian/rules clean * Set urgency=medium as this fixes serious FTBFS bugs. -- Jonas Smedegaard Sat, 28 Jun 2008 16:54:40 +0200 libgd2 (2.0.36~rc1~dfsg-2) unstable; urgency=medium * Add symbols file. * Add patch 0001 to fix leak in gdImageCopyResized. * Set urgency=medium, as the bugfix above seems security-related. * Update local cdbs snippets: + Enable patchsys-quilt.mk. + Major improvements to update-tarball (but none of them affecting this current packaging). + Major improvements to copyright-check, including new versioned build-dependency on devscripts. Update debian/copyright_hints. Closes: bug#466642. + Drop buildcore.mk override. Set DEB_AUTO_UPDATE_DEBIAN_CONTROL directly instead when needed. + Update debian/README.cdbs-tweaks * Avoid copyright-check choking on config/install.sh and aclocal.m4. * Semi-auto-update debian/control to update build-dependencies: DEB_AUTO_UPDATE_DEBIAN_CONTROL=yes fakeroot debian/rules clean -- Jonas Smedegaard Sat, 12 Apr 2008 00:49:13 +0200 libgd2 (2.0.36~rc1~dfsg-1) unstable; urgency=medium * New upstream prerelease. + Fixed gdImageCopy with true color image, the transparent color was ignored + Fixed support of PNG grayscale image with alpha channel + _gdCreateFromFile() can crash if gdImageCreate fails + gdImageCreateFrom*Ptr() can crash if gdNewDynamicCtxEx() fails + gdImageRectangle draws 1x1 rectangles as 1x3 rectangles + Possible integer overflow in gdImageFill() + Optimization for single pixel line not in correct order + gdImageColorDeallocate can write outside buffer + gdImageColorTransparent can write outside buffer + gdImageWBMPCtx can crash when createwbmp fails * Set urgency=medium due to this being a bugfix-only release, and some of the fixes seems security-related. * Move Homepage to own field (from pseudo-field in long description). * Move XS-Vcs-* control fields to Vcs-*. * Add patch 0003 to fix segfault when createwbmp fails. * Adjust watch file: + Include upstream prereleases + Ignore local trailing ~dfsg repackaging hint + Invoke svn-upgrade (not uupdate) * Update cdbs tweaks: + Support zip in upstream-tarball.mk (unneeded here) + Use ~ as repackaging delimiter in upstream-tarball.mk to make room for point releases and cleaned up rerelease + Rename top srcdir in repackaged tarball to $pkg-$ver.orig to comply with Developers Reference 6.7.8.2. + Support mangling upstream version string in upstream-tarball.mk + Drop buildcore.mk override (set DEB_AUTO_UPDATE_DEBIAN_CONTROL manually when needed instead) * Drop all patches: applied upstream. * Strip tests from repackaged source tarball: newly added truetype font comes without license, and all tests are unusable anyway without cmake modules that are already stripped. * Document stripped files in debian/copyright. * Update debian/copyright_hints (newer years for automade files). * Bump standards-version to 3.7.3 (no changes needed). * Semi-auto-update debian/control: DEB_AUTO_UPDATE_DEBIAN_CONTROL=yes fakeroot debian/rules -- Jonas Smedegaard Thu, 03 Jan 2008 16:14:46 +0100 libgd2 (2.0.35.dfsg-3) unstable; urgency=high * Add patch hand-picked from upstream CVS: + gdImageColorTransparent can write outside buffer * Raise to urgency=high as this a small, security-related bugfix. -- Jonas Smedegaard Sun, 16 Sep 2007 21:57:28 +0200 libgd2 (2.0.35.dfsg-2) unstable; urgency=medium * Add patch (using patchsystem-quilt.mk cdbs snippet) hand-picked from upstream CVS to fix various security-related issues: + _gdCreateFromFile() can crash if gdImageCreate fails + gdImageCreateFrom*Ptr() can crash if gdNewDynamicCtxEx() + gdImageRectangle draws 1x1 rectangles as 1x3 rectangles + Possible integer overflow in gdImageFill() + Optimization for single pixel line not in correct order + gdImageColorDeallocate can write outside buffer * Add XS-Vcs-Svn and XS-Vcs-Browser fields to debian/control. * Update cdbs tweaks: + Support non-dot-delimited repackaging tag in update-tarball. + update-tarball needs recent cdbs (only relevant for backports). * Cleanup duplicate build-dependencies in debian/rules. * Semi-auto-update debian/control: DEB_BUILD_OPTIONS=cdbs-autoupdate fakeroot debian/rules pre-build * Fix shlibs dependencies: Use DEB_UPSTREAM_VERSION (instead of custom version variables). * Set urgenvy=medium due to the security-related fixes. -- Jonas Smedegaard Tue, 04 Sep 2007 20:28:46 +0200 libgd2 (2.0.35.dfsg-1) unstable; urgency=low * New upstream release. Closes: bug#431443, thanks to Sean Finney. * Repackage source tarball to avoid files below VMS and cmake that contains copyrights with questionable or missing licensing info. * Switch to team maintainance using Alioth project pkg-gd, and myself and Sean Finney as uploaders. Others interested in helping out maintaining packaging of GD and related packages, please get in touch with us at pgk-gd-devel@lists.alioth.debian.org . * Update CDBS tweaks: + Minor improvements to upstream-tarball.mk. + Advertise debian/README.cdbs-tweaks in debian/rules. * Replace deprecated ${Source-Version} with Use binNMU-safe ${binary:Version} in debian/control. Thanks to Lintian. * Update debian/copyright to include new copyright (BSD) for the file strlcpy.c. -- Jonas Smedegaard Sun, 12 Aug 2007 13:40:55 +0200 libgd2 (2.0.34-1) unstable; urgency=low * New upstream release. * Update cdbs tweaks: + Switch from vcs.mk to improved upstream-tarball.mk. + Minor updates to copyright-check. + Minor documentation updates. * Use debhelper.mk cdbs snippet (greatly simplifies custom rules). * No longer set library version (upstream takes care of this now). * Use www.libgd.org (not just libgd.org) as homepage. * Update watch file to use new upstream source (ignoring prereleases). * Cleanup package dependencies: + Provide virtual packages libgd-dev and libgd2. + Drop conflicts on pre-Sarge packages. + Fix conflicting with libgd-noxpm-dev (was libgd-xpm-dev twice). * Fix old changelog entry closing bug#167976, to please lintian. -- Jonas Smedegaard Thu, 17 May 2007 12:29:12 +0200 libgd2 (2.0.34~rc1-1) unstable; urgency=high * New upstream prerelease. * Drop all patches. Bugfixing patches are all either adopted or differently implemented upstream now, and the only feature patch to improve anti-aliasing is recommended by upstream to be avoided for now (will be included in later releases of GD). * Drop pthreads workaround. Upstream now properly handles this. * Avoid fallback build-dependencies on xlibs-dev, thanks to lintian. Avoid *-dev package dependencies too, and tighten build-dependency on d-shlibs to versions supporting the neat new runtime override feature of d-devlibdeps used for this. * Drop duplicate build-dependency on autotools-dev, thanks to lintian. * Bump up standards-version to 3.7.2. * Update debian/copyright and long descriptions with new upstream author and new upstream URLs. * Semi-autoupdate debian/control to have the above take effect: $ DEB_BUILD_OPTIONS=cdbs-autoupdate fakeroot debian/rules clean * Update debian/copyright-hints due to the relibtoolization. * Add new CDBS snippet vcs.mk hinting about the source environment. * Fix copyright-check CDBS snippet to properly ignore also CDBS-overridden autotools files. * Set urgency high, as the older pathced code is known to contain several bugs fixed in current upstream code. Work is ongoing about resolving if any of those bugs have known security issues with an official CVE. -- Jonas Smedegaard Tue, 30 Jan 2007 15:06:48 +0100 libgd2 (2.0.33-6) unstable; urgency=high * Acknowledge NMUs. Closes: bug#384838, #383747. Thanks to Paul and Martín Ferrari, and to Andreas Barth and Steinar H. Gunderson for watching my back. * Update local cdbs snippets (and add debian/README.cdbs-tweaks to source, documenting their purpose), fixing a FTBFS. Closes: bug#396174, thanks to Martin Pitt. * Semi-autoupdate debian/control to have the above take effect: $ DEB_BUILD_OPTIONS=cdbs-autoupdate fakeroot debian/rules clean * Add patch 1009 to fix segfaults due to lack of boundary checks for anti-aliasing. Closes: bug#404774, thanks (again!) to Paul. * Set urgency=high as the above is important to include with etch. -- Jonas Smedegaard Mon, 1 Jan 2007 20:18:13 +0100 libgd2 (2.0.33-5.2) unstable; urgency=high * Non-maintainer upload. * remove 1006_western_european_fonts.patch, as this breaks (at least) two different packages, and creates issues for people with central european encoding. It is also an unnecessary derivation from upstream. Closes: #383747 -- Andreas Barth Wed, 29 Nov 2006 16:34:54 +0000 libgd2 (2.0.33-5.1) unstable; urgency=medium * Non-maintainer upload. * 1008_segfault_invalid_gif.patch: New patch, adapted by Stefan Fritsch; fixes segfault (and possible security issue) when reading some forms of corrupted GIFs. (Closes: #384838) -- Steinar H. Gunderson Mon, 11 Sep 2006 01:24:24 +0200 libgd2 (2.0.33-5) unstable; urgency=low * Merge patch 1002 with different approach from ubuntu, and rename as 1002_CVE-2006-2906 now that the bug (infinite loop in GIF code) has an official name. Closes: bug#372912 (thanks to Alec Berryman for reporting, and to Martin Pitt for providing a patch). * Add patch to switch to western european fonts (ISO8859-1/ISO8859-15) instead of the current eastern european (ISO8859-2). * Add --without-xpm option to configure when compiling -noxpm variant. Closes: bug#370572 (thanks to Omniflux ). * Indent Homepage string in long descriptions. * Add patch 1007 to avoid advertising external libraries in gdlib-config script (advertise them in new --static-libs instead). Closes: bug#375806 (thanks to Samuel Thibault ). -- Jonas Smedegaard Mon, 17 Jul 2006 02:15:53 +0200 libgd2 (2.0.33-4) unstable; urgency=low * Have libgd-noxpm-dev provide libgd2-dev (a virtual package since woody). libgd-xpm-dev does not provide it, as the two packages does not provide same shlibdeps info: Both provide same ABI but not same package dependencies, so those requiring XPM support will want to explicitly (build-)depend on that variant. Closes: bug#350704, #358306 (thanks to Daniel Schepler and Martin Michlmayr for reporting, and to Junichi Uekawa for patience and helpful input). * Use quilt (instead of CDBS builtin patch routines). * Use local cdbs snippet to enable debian-control (semi-)auto-update. * Update local cdbs snippet buildinfo.mk: + Correct namespace. * Update local cdbs snippet copyright-check.mk: + Correct namespace. + Treat all found files as non-binary. + Broaden scan to also look for "(c)" by default. + Make egrep options configurable. * Semi-auto-update debian/control (nothing remarkable). * Semi-auto-update debian/copyright_hints (nothing remarkable). * Renumber and unfuzz patches, and add debian/patches/README documenting the new numbering scheme. * Add patch 1003 fixing an antialiasing segfault. Closes: bug#364024 (thanks to Paul ). * Add patch 1004 improving antialiasing lines at image edges (thanks to Paul ). * Add patch 1005 to more sanely bail out on missing or wrong data, and include config.h also for tools and examples. This closes: bug#360966 (thanks to the Graphviz project were these was extracted from, and to Matthias Klose reporting it). -- Jonas Smedegaard Sun, 21 May 2006 09:51:07 +0200 libgd2 (2.0.33-3) unstable; urgency=low * Update debian/rules only if DEB_BUILD_OPTIONS contains "update". * Auto-update debian/rules (and manually strip bogus build-dependency on build-essential). * Upgrade watch file to version 3. * Standards version 3.6.2. * Mention homepage (not website) on long descriptions. * Add new local cdbs snippet copyright-check.mk. * Update debian/copyright with differing (but still DFSG-free) licensing of gd_gif_out.c (thanks to copyright-check.mk). * Update TODO with a bunch of entries to the "packaging hall of shame" (list of packages without -noxpm support). * Add patch to not treat negative return values from buffer routines as ok. Closes: bug#308981, #312500 (both thanks to Jim Meyering ). * Dropped old transitional packages libgd2 and libgd2-dev. Closes: bug#322044 (thanks to Javier Fernández-Sanguino Peña ). -- Jonas Smedegaard Thu, 8 Dec 2005 02:29:44 +0100 libgd2 (2.0.33-2) unstable; urgency=low * Acknowledge NMU. Closes: bug#278625, #283991 (thanks to Martin Pitt , Steve Kemp and others). * Revert order of dependencies for transitional packages to favor -xpm over -noxpm, and thus avoid surprises when upgrading from woody. Closes: bug#291783 (thanks to Don Armstrong ). * Rerun "libtoolize -c -f; aclocal-1.9; autoconf" with newer autotools. * Use cdbs (except debhelper snippet: too big change for now). * Define version strings "simply expanded" (small compile speedup). -- Jonas Smedegaard Thu, 21 Apr 2005 16:10:34 +0200 libgd2 (2.0.33-1.1) unstable; urgency=high * Non-maintainer upload with permission from Jonas * Apply patch to close security hole CAN-2004-0941 -- Steve Kemp Thur, 3 Dec 2004 19:09:54 +0000 libgd2 (2.0.33-1) unstable; urgency=low * New upstream release. + Improved font handling. Closes: Bug#281349 (thanks to Alexander Schories ). * Improve build rules to support kfreebsd-gnu. Closes: Bug#268280 (thanks to Robert Millan ), and probably also bug#276441 (but leaving open until confirmed). + Patch autoconf.ac to work around broken detection of pthreads. + Run "libtoolize -c -f; aclocal-1.9; autoconf" once. + Include the above patch with source, for use with newer upstream releases. + Update config.guess and config.sub at build time. + Build-depend on autotools-dev for the above. + Update config.rpath from http://savannah.gnu.org/projects/gnulib (grabbed from CVS). * Build -noxpm variant without fontconfig support as well (and add TODO note about possibly renaming to -nobloat in the future). * Mention fontconfig support (or lack thereof) to long descriptions. Closes: bug#280369 (thanks to Josip Rodin and Julian Mehnle ). * Drop obsolete and unused debian/rocks file. * Update TODO: rrdtool now properly acknowledges -noxpm (at last!). -- Jonas Smedegaard Sun, 7 Nov 2004 14:08:29 +0100 libgd2 (2.0.30-1) unstable; urgency=high * New upstream release: + Security fix: potential buffer overflow (CAN-2004-0990). Closes: bug#278625 (thanks to Martin Pitt ). * Tightened d-devlibdeps build-dependency (local hack is adopted now). * New fontconfig support enabled. * Include "hall of shame" to TODO. * Set urgency=high as this closes a security-related bug in sarge. -- Jonas Smedegaard Sat, 30 Oct 2004 22:22:10 +0200 libgd2 (2.0.28-3) unstable; urgency=high * Acknowledge NMU (thanks to Simon Richter for noticing and Steve Langasek for providing the fix). The bugreport contains other less urgent parts not fixed by this package, so will be split/closed manually. * Temporarily use local hacked d-devlibdeps that correctly (more or less, but at least better than before) resolve the recent X11 package split (bugreport filed against devlibs). * Clean out test gif's on clean target (in addition to png's). * Keep urgency=high for the RC bugfix to reach sarge, and because all the changes affects no binaries, only packaging hints. -- Jonas Smedegaard Mon, 13 Sep 2004 18:29:45 +0200 libgd2 (2.0.28-2.1) unstable; urgency=high * Non-maintainer upload. * High-urgency upload for sarge-targetted RC fix. * Add build-dependency on libxt-dev to ensure that libgd2-xpm really does support XPMs (closes: #270655). -- Steve Langasek Wed, 22 Sep 2004 04:32:23 -0700 libgd2 (2.0.28-2) unstable; urgency=low * Build-depend on libx11-dev (in addition to libxpm-dev) to actually include XPM support in the -xpm packages (broken on all but powerpc since 2.0.23-1), and configure explicitly using --with-xpm to hopfully fail less silently in the future. Thanks to Matt Zimmerman for spotting the bug. -- Jonas Smedegaard Wed, 28 Jul 2004 11:17:10 +0200 libgd2 (2.0.28-1) unstable; urgency=low * New upstream release. Closes:Bug#260793 (thanks to Adam Conrad ). * Drop TODO about dropping noxpm packages: Even with the new fine- grained packaging of X11 libraries XPM support still pulls in several megabytes irrelevant for most web server applications (the most popular usage of GD). * Minor corrections to gdlib-config man page. -- Jonas Smedegaard Thu, 22 Jul 2004 14:18:45 +0200 libgd2 (2.0.27-1) unstable; urgency=low * New upstream release. Closes: Bug# 254569 (except request for LZW support - I rely on the good judgement of upstream. Thanks anyway to Domenico Andreoli for the suggestion). * Cleaned up debian/copyright: + Replace info contained in changelog with note on "GNU systems". + Declare each topic more strictly. + Mention "licensing info" together with copyright. * Improved long descriptions: + General introduction to GD in all (non-transitional) packages + Website URL added -- Jonas Smedegaard Sat, 17 Jul 2004 15:03:27 +0200 libgd2 (2.0.23-2) unstable; urgency=low * Rebuild to override secret NMU (HEY!!! when did we change rules to not need to warn before doing an NMU?!?). Still closes: Bug#243500, #238890. -- Jonas Smedegaard Thu, 22 Apr 2004 00:36:44 +0200 libgd2 (2.0.23-1) unstable; urgency=low * New upstream release. Closes: Bug#243500 (thanks to Jan-Åke Larsson ). * Acknowledge NMU. Closes: Bug#238890 (thanks to Domenico Andreoli ). * Build-depend on libxpm-dev, with only a fallback to older xlibs-dev. * Use (and build-depend on) dh_buildinfo. * Add debian/TODO to source package, with notes on noxpm branch and interest in switching to cdbs (bzzzt, this changelog entry should *not* count in the "taking over the world" statistics of cdbs ;-) ). -- Jonas Smedegaard Wed, 21 Apr 2004 23:36:28 +0200 libgd2 (2.0.22-0.1) unstable; urgency=low * New upstream release. Closes: Bug#238890. * This is a NMU. -- Domenico Andreoli Fri, 19 Mar 2004 18:09:11 +0100 libgd2 (2.0.20-1) unstable; urgency=low * New upstream release. Closes: Bug#226179. -- Jonas Smedegaard Fri, 9 Jan 2004 03:58:46 +0100 libgd2 (2.0.16-1) unstable; urgency=low * New upstream release. * FreeType headers are now properly handled. Closes: Bug#224789. * Bump up (and correct syntax of) standards-version to 3.6.1 (no changes needed). Closes: Bug#210415. -- Jonas Smedegaard Thu, 25 Dec 2003 00:35:51 +0100 libgd2 (2.0.15-1) unstable; urgency=low * New upstream release. * Standards version 3.6 (no changes needed). -- Jonas Smedegaard Tue, 22 Jul 2003 11:54:41 +0200 libgd2 (2.0.12-2) unstable; urgency=low * Have development packages conflict with libgd-gif1-dev. This relates to Bug#191039 (thanks to Martin Schulze ). * This package complies with Debian Policy 3.5.10. -- Jonas Smedegaard Fri, 16 May 2003 17:56:22 +0200 libgd2 (2.0.12-1) unstable; urgency=low * New upstream release. * Correct paths to shared libraries for generating -dev dependencies. * Switch debhelper hint from DH_COMPAT to debian/compat. * Claim compliance with Policy 3.5.9 (no changes needed). * Change section devel to libdevel. * Run configure using --disable-rpath (although it is still ignored). -- Jonas Smedegaard Sun, 13 Apr 2003 22:39:43 +0200 libgd2 (2.0.11-3) unstable; urgency=low * Update doc_cleaner.pl to make html file completely weblint-clean (required for woody, so closes: Bug#185492). -- Jonas Smedegaard Wed, 19 Mar 2003 23:38:54 +0100 libgd2 (2.0.11-2) unstable; urgency=low * Simplify debian/rules a bit: Remove the INSTALL* definitions that may have stripped the binaries (not sure if it is honoured by the automade Makefile, but better safe than sorry). -- Jonas Smedegaard Fri, 7 Mar 2003 01:29:49 +0100 libgd2 (2.0.11-1) unstable; urgency=low * New upstream release (closes: Bug#170353). * Adapt debian/rules to the new proper configure script. * Drop DBS and use plain debhelper instead. Adapt build-depends. * Use homebrewn debian/doc_cleaner.pl to clean the html doc instead of a patch (more sustainable if upstream chooses to not fix the horrible html with next release). * Mention new binary annotate in libgd-tools.1 manpage and add a symlink. * Remove obsolete dh_undocumented from debian/rules. * Add a minimal manpage for the new helper script gdlib-config. -- Jonas Smedegaard Sun, 16 Feb 2003 02:00:42 +0100 libgd2 (2.0.4-11) unstable; urgency=low * Relax dependency for transitional packages of their real counterparts. -- Jonas Smedegaard Mon, 16 Dec 2002 02:02:35 +0100 libgd2 (2.0.4-10) unstable; urgency=low * Use d-shlibdeps package again, and build-depend on corrected versions of the package. * Declare compliance with Policy version 3.5.8.0 (no changed needed). * Remove full stop in description to please lintian. -- Jonas Smedegaard Mon, 16 Dec 2002 01:50:10 +0100 libgd2 (2.0.4-9) unstable; urgency=medium * The "Will we ever make it in time...?" release. * Use a local hacked d-devlibdeps (to properly handle libXpm dependency), and remove build-depend on d-shlibs. * Use html2text instead of w3m (as w3m doesn't build on all platforms). Thanks to Adam Conrad for pointing it out. Hack the html to be weblint-clean for html2text to accept it. * Set urgency=medium - same argument as below. -- Jonas Smedegaard Sun, 24 Nov 2002 21:01:27 +0100 libgd2 (2.0.4-8) unstable; urgency=high * Have libgd2-(no)xpm replace libgd2 older than 2.0.4-2 (when it became a transitional package, instead of a virtual on (which is ignored by Replaces:), and instead of the old plain package). * Set urgency=high, as only change is with this extra hint, and we really want this in testing soon - even with the current (unreported) bug it does more good than harm to let it in. -- Jonas Smedegaard Thu, 21 Nov 2002 06:36:41 +0100 libgd2 (2.0.4-7) unstable; urgency=low * Conflict with old virtual libgd2(-dev) packages (closes: Bug#16881). -- Jonas Smedegaard Wed, 13 Nov 2002 00:16:26 +0100 libgd2 (2.0.4-6) unstable; urgency=low * Preload libgd.so when running tests. Allows building without libgd2 already installed, and closes: Bug#167976. -- Jonas Smedegaard Wed, 6 Nov 2002 06:03:09 +0100 libgd2 (2.0.4-5) unstable; urgency=low * Have -dev packages conflict on libgd-(no)xpm-dev. * Have only transitional packages provide and conflict libgd1g, libgd1-altdev and old -tools packages. * Change build-depends to only the virtual libz-dev and libpng12-dev (not their real counterparts as well). * Add watch file. -- Jonas Smedegaard Wed, 6 Nov 2002 05:25:56 +0100 libgd2 (2.0.4-4) unstable; urgency=low * Use (and build-depend on) d-shlibs to make proper depends for -dev packages. * Tidy debian/ by generating debhelper files in configure target and remove it on clean. -- Jonas Smedegaard Mon, 4 Nov 2002 19:00:36 +0100 libgd2 (2.0.4-3) unstable; urgency=low * Correct dependencies for transitional packages. -- Jonas Smedegaard Mon, 4 Nov 2002 17:33:31 +0100 libgd2 (2.0.4-2) unstable; urgency=low * Provide transitional packages (a virtual package cannot satisfy a versioned dependency). * Tighten libgd2-xpm-dev to only same lib (noxpm binaries work well with xpm lib, but not the other way around). * Generate shlibs files without debhelper (to correctly do the above). * Simplify dh_shlibdeps invocation (it is really only used for libgd-tools anyway) and avoid using -L flag (to allow rebuild on woody with debhelper << 4.1.1 where the flag first appeared). * Enable tests (gddemo and gdtest). * Include test images as examples in -dev packages. * Remove TODO.Debian (the item - warnings possibly caused by signedness problems - have been dealt with upstream). -- Jonas Smedegaard Mon, 4 Nov 2002 15:30:29 +0100 libgd2 (2.0.4-1) unstable; urgency=low * New upstream release. * Update gdft patch 02add_gdImageStringFTEx. * Update configure patch 01makefile_generic_install. * Make sure not to compile libgd.a with -fPIC. * Corrections to debian/rules to adapt to new configure. -- Jonas Smedegaard Mon, 28 Oct 2002 02:40:39 +0100 libgd2 (2.0.2-2) unstable; urgency=low * Add unofficial function gdImageStringFTEx to not break binary compatibility with 2.0.1 (thanks to Nils Rennebarth for complaining and providing the patch. * Fix building without libgd2-dev already installed. * Fix linking libgd-tools against libgd2-noxpm (not static built). * Suggest noxpm in favor of xpm for packages built against noxpm. * Build-depend on new libpng12-0-dev and on zlib1g-dev, with fallback to their virtual packages. -- Jonas Smedegaard Sat, 26 Oct 2002 10:32:56 +0200 libgd2 (2.0.2-1) unstable; urgency=low * New upstream version. + Antialiased freetype text output now works properly in both truecolor and non-truecolor contexts! + By default, alpha blending is now done within the library. Also, by default, alpha channel is not saved with PNG images. * Repackage using dbs (with no patches applied for now). * Readme only html now, so build a text version (and build-depend on w3m). * Update debian/copyright (years added, and contact address changed). * Correct libgd-tools dependency on libgd2-(no)xpm. * Build and run tests. -- Jonas Smedegaard Tue, 22 Oct 2002 01:46:22 +0200 libgd2 (2.0.1-19) unstable; urgency=low * Conflict with libgd2 (and closes: #158639, #157920). -- Jonas Smedegaard Thu, 29 Aug 2002 03:50:26 +0200 libgd2 (2.0.1-18) unstable; urgency=low * Build against libpng3 (thanks to Junichi Uekawa for cleaning up the mess finally!). -- Jonas Smedegaard Sun, 18 Aug 2002 18:30:28 +0200 libgd2 (2.0.1-17) unstable; urgency=low * Install libgd-tools.1 (closes: #130499). -- Jonas Smedegaard Sun, 11 Aug 2002 02:41:02 +0200 libgd2 (2.0.1-16) unstable; urgency=low * Correct shlibs dependency on libgd2-xpm (not the virtual libgd2). Thanks to Chris Halls for spotting the error, which closes: #155498. -- Jonas Smedegaard Mon, 5 Aug 2002 16:58:06 +0200 libgd2 (2.0.1-15) unstable; urgency=low * Patch gdft.c for truecolor antialiasing. Patch found at http://www.coupin.net/gd-freetype/ thanks to Michael Ganss , and closes: #154112. -- Jonas Smedegaard Mon, 29 Jul 2002 04:04:52 +0200 libgd2 (2.0.1-14) unstable; urgency=low * Correct bug related to color resolving, thanks to Egon Eckert . -- Jonas Smedegaard Sun, 28 Jul 2002 10:28:30 +0200 libgd2 (2.0.1-13) unstable; urgency=low * libgd2-xpm-dev should depend on libgd2-xpm, not libgd2. -- Jonas Smedegaard Sat, 13 Jul 2002 17:33:04 +0200 libgd2 (2.0.1-12) unstable; urgency=low * Include docs in all packages. -- Jonas Smedegaard Sat, 13 Jul 2002 17:21:20 +0200 libgd2 (2.0.1-11) unstable; urgency=low * The "No more potatoes" release. * Major rewrite of debian/* to use debhelper V4. * Remove libgd.a from libgd-tools. * Rename libgd2 to libgd2-xpm and use libgd2 as a virtual package. * Add new package libgd2-noxpm-dev and do the same rename as above with -dev. * Include all header files (some where left out) in -dev packages. * Tighten shlib dependency to at least this build to avoid the old mess... * Add all demos from libgd-tools as example source in -dev. Remove compiled demos from -tools. * Add debug and nostrip support to debian/rules. * Add contact address gd@boutell.com to debian/copyright. * Remove libgd-tools Conflicts on libgd2-noxpm - they should work fine together (none of the tools use xpm). * Move libgd-tools Conflicts and Replaces on older libgd-tools to libgd2-xpm and -noxpm to make lintian happier. Suggest -tools as well. * Include/improve comment about XPM for long descriptions. * Set sane access rights on whole source as part of clean target. * Write a manpage for the libgd-tools applications to please lintian (and the rest of the world). This closes: Bug#130499. -- Jonas Smedegaard Sat, 13 Jul 2002 16:20:27 +0200 libgd2 (2.0.1-10) unstable; urgency=low * Correct a typo (my fault!) whith the patch. This closes: bug#142946. -- Jonas Smedegaard Mon, 15 Apr 2002 11:22:32 +0200 libgd2 (2.0.1-9) unstable; urgency=low * Change ligd-tools priority from extra to optional. * Include patch from Stephen to handle antialiasing (let's hope we make it for Woody). -- Jonas Smedegaard Wed, 10 Apr 2002 12:48:11 +0200 libgd2 (2.0.1-8) unstable; urgency=low * Add both xpm and non-xpm to substvars files, thanks to Joey Hess. * Now that we are at it: Loosen up shlibs dependencies. -- Jonas Smedegaard Mon, 25 Mar 2002 22:46:10 +0100 libgd2 (2.0.1-7) unstable; urgency=low * Oops - now _really_ loosen up libpng2-dev dependency... -- Jonas Smedegaard Fri, 22 Feb 2002 04:43:53 +0100 libgd2 (2.0.1-6) unstable; urgency=low * Reflect changes in (NMU of) libpng3 and only Build-conflicts: the badly hinted one, to loosen up libpng2 dependency to all _real_ releases available (and possibly libpng3 if indeed it is/becomes as compatible as claimed!). * Change libgd-tools priority and libgd2-dev section to make Debian Installer happy. -- Jonas Smedegaard Fri, 22 Feb 2002 02:10:37 +0100 libgd2 (2.0.1-5) unstable; urgency=low * Build a -noxpm variant. -- Jonas Smedegaard Fri, 1 Feb 2002 02:49:59 +0100 libgd2 (2.0.1-4) unstable; urgency=low * Another workaround to the libpng{2,3} mess: build-depend on specific version to avoid illegal versioned build-conflict on (sometimes!) virtual package. This will probably cause problems on autobuilders as well (if they still see replacing libpng-dev with libpng2-dev as a downgrade), but should at least be legal. * Add readme.* to libgd2-dev. -- Jonas Smedegaard Sun, 20 Jan 2002 15:08:43 +0100 libgd2 (2.0.1-3) unstable; urgency=low * Put back conflicts/replaces on libgd-tools (<<2.0.0). They where needed after all (even though lintian complains). -- Jonas Smedegaard Sun, 13 Jan 2002 16:19:51 +0100 libgd2 (2.0.1-2) unstable; urgency=low * New maintainer (thanks, Ivo :-). Updating maintainer field. * Strip non-libgd2 part of changelog (go read the one from libgd package if interested in older changes). * Updating copyright file (Closes: #119288). * Cleanup old freetype2 (FreeType1) mess. * Use debhelper V3, tighten Build-Dependency on debhelper accordingly and remove postinst to have debhelper handle ldconfig correctly. * Build-Conflicts: libpng-dev (>= 1.2) (stuff like libgd-perl needs to know wether png2 or png3 is used - let's be conservative for a start). * Remove duplicate dependencies and strange conflicts/replaces (probably wrongly converted from those against libgd1g in libgd) in debian/control. -- Jonas Smedegaard Sun, 13 Jan 2002 15:50:02 +0100 libgd2 (2.0.1-1) unstable; urgency=low * Initial package, based upon libgd1. (Closes: #102179, #102494) -- Ivo Timmermans Sat, 18 Aug 2001 19:55:14 +0200 tests/gif/unitialized_memory_read.gif0000644000000000000000000002631013143155457015260 0ustar GIF89a, H?*\诟Ç#Gŋiȱ>} C/ɓ(SDz˗ɜI={8siϟ@֣Gѣ)]ʴ{J/Wy;zG{S|_G} ~". H:F)R9^IHYi yh,8(DP\(58%1 y=9I)U9aIIeCVb\v#a IfFl$q8W|V'nZhX%`J&h&p:*jy9{+*+:+JK#Z)j{)z)P#;;l쬣 7:G,cg:w#$|9(0\94l䌣<<8@-cH'8L7+VX;d_ ,p5lD| MO=Vg5\b]6hn7t}z7 .5U5[+5a;N6gK6m[7skn7y{7n/.001 n2,.383D4P _/0+0;1K_2+[37k3C{4Oȧ/ }S'1a ~2 6'4! N /j S 1  (2 4 84 LHXB SXX1n !h2 9xX4. Q"eD$&QLl ER6bu.axD*q,ta()ЊWġC/~Bh?Ql,)EёxˈDK2P$9EOr`$IG%^҉&I-~ҋ,MXI[*yJ_& )YJcT!Hg6@8Ir~L:ng7Az؆>~nC @lMh6І:ظD'Jъ^ͨF7jjx i5AҒԘJWҖNC0Lg*h8i4Ӟ0P΢SH}'>ZO:uj@JՃB V'ѮfT`(JZRu4MkLu֛=PjԤ&L}S*ժVXVհd=YժֶpPZT"KիSURWV UÂcUYVDzo9)NԬ?9KP*EIQӊ(UKYKS@m9iNm?y;P&nEQ'UnK;S?.9N.?+P"/EɫQ&U/K+S>/QN*/T PZ 0W Q$U0Z S<8)\a ?9\P/EIQ)UKY\SA1icX<d&FrU&Qm|c xA,!GFb'?2>'l7gY\,=hcC@V4dG3P)fljh%?ɑ-\hS_ՙVYiW֡5 ]i[tyg_0~Mj?ζfxw3ArXv/C筌dw2~8NOnb8x1A[7C G.`(Oy0̧g[86w^nw|zM{6'\P8Ƨ^q[}$zU-mn<υ.H_ҝGTյw`^s;WtGtCS׻us_ mËVOo)pK׼9Orϫ0}ImӇV}Y?o}ipG}y?rߧ/>mV>/o>pC>ǹ/r.'~4G~f~:~~@~~F&LGgRX ^,'Fhㆀ馀ƀ'G gǁ%+1'$m&),؂1(4X9<؃A(Ch'* /28h7:?"xm$ȅFI(LXORUX[X(h,04ȇ8<@(sH^wy({h}胁(huhȉ艏(HhadgȊjm 8X Șʸ  Xx ڸ؍ 8 x蘎 ؎p 8X` P @ Yy0 ِ 9 y ّ`"9X((ظ.ᨎ4yxh:9ؓ(@9FLy 9#i&)ɒ,/)2Y58;>AIDyGJٔM P)"I%i(+.ɕ14 7):I=i@CFɖIL O)Hh҈بȗ(Hhɘ )Hhшרș(Hh ɚ )HhЈ֨ț(Hh ɜ )$Ih*Ԩ0ɝ6 ( +JkÊɪʾ *Jjʿ +ܫ ,\ !,#l  WY,[l]_a,slUlgikmo q,KelADGJM <ʤ\ʟ ʪʞ ʰ˝ \˶|˜ ˼˛ <̚ |Ȝ̙ ̘p <\͗` ؜ڼ͖P Ε@ \|Δ0 Γ <ϒ |ϑ ϐ`=ʬ\Щ,ʸе}|l=, <&,}<m -]!M$}'*- 0-Mm  -Mm #&), /-զLլlղով ,Ll -ץL׫lױ׷׽ ,Ll ,٤L٪lٰٶټ ,Ll ,Mۨl ۴ ,Ml"(. ,ݢLmݳݹݿ ,Ll - .^ .n >m }.^"%(+^m .CN.GI.KnMOQ.cnEnWY[]_a.MUn147:=>^难^~ꌰꋠ>느~븞뉀p>^`ȞʾP@^~0ھ >~`>^.騾~n ?.>>n._ O /Nn/ O o/Nn.NnҎخ.Nn.Nnю׮.Nn.NnЎ֮.Nn. OnԮ.No.Nnӎٮ$XA zCMXѢF5n؈G!E2ZTIdҥD1eΤM9u":O %ZԨBI.eZSQTUmիa .${0YRVH S5.˚ye3_GmZXTP.1W-ڵnƍKݻz  'N̘ǒR&k,fry.hk/j Fz1lDz^h;";;%ki<(ʛ2<+RGh"v9r%xģ< =c= >#{ۈ;  \ ®$BFs{G?rH"$TrI>pI(C*J=rK.0sL<0L4Ӽ6tM;sN:묃`Dv`J .%+%1-N75==CEnIMeU&e%]f+ef1mFg7ug=}hCfhIii$&j*Vj0k6k<lBlHͶ>&ݞ,2^8>DJ G]vq%n/[sEpwDxՇoxؓy۟]zޫ=uƵ{ʽ||Ϳ}^-^yn|+o}k p~ц)x DAI0z$LxB n`a ]B7A3a P;d|C q j bxD5AKdbӀ(FQSDxE,f fbE3Ac$c@4Qk$F8q bcxG1A{c@R yB&6d y Q?Db%DL.=yE0f$x4Qoc+GX !HE6$'iIKf2'?)JQD*WJW2- D꒑|/% J ܤ1=P*<3U VJԜ5UMjӆ7N$Ӊ䤢9N0ӌd;O<ӏ$=S곆ܡ?# A/* ]C;JEQQjաGR#$IR/,UKS;ʔ4MSԑ<šO) T" UDQAT.*ՔLESY U:JUTUMլj\W$dY0lm[|?x| 'o|ѻ}r}/ᯯko䯾䫿GWדأ?{<@L'pl@|@'h @ &` @ @&X@ %P,A?DA,BDDD\EtDGHDJD34D67D9:E<$=4E?D@TEBdCtEEFEHIEEE EEFF$F4FDF TF#dF&tF)F,F/F2 $4DT"d%t(+.1GGG G GHH$H4HDHTH"dH%tH(H+H.H1H4HH7H H:II=$I4I@DITICdI$tIFI*III0Iɜ $4D T#d&t),/2J@ʮI K$˲4JLKd˶tJK˺ɻʭIJ˱$JU@%A5UDUUUeUuU U UUUUUUU!V$V'%V*5DTeu  #&%)5WDWTWeWuWW WWWWWWW X#X&%X)5X,EXTX/eXuX2X X5XX8XX;XX>Y"YA%Y(5YDٔUeu !$'%*5Z PeڦuYZڪYZڮY [%۲5ٳUڥeY}ZکYZڭYZ۱%ZO\ܶ5\Mܹe\}ܼ\ܿM[\\\]]%]5E]u͕ε5U%5^Ue^uŅ^Ǖȥ^}=_Mpm_}_h_`__X_P.`>`H^`n@` `8 ` 0``(a. Na^a~aaaa b!bP_#>_M_&_}`)_v`,^` `/`6a2a>a5~ana8a" >#Vb%n&b()b+,b./c1.2Fc4^5vc78c:c#$c&'c)*d,&-6d/F0Vd2f3vd56d89dddddee&e 6e FeVefeveeee"& 6 FVfv!fffffgg&g 6g FgVgfgvgggg!g$gg'gg*hh-&h6h0FhVh3fhvh6hh9h h& 6 FVfv"i_hj&6iNjfvijꪶhi&i>jVfi~jꩦi^_k뮶kkl.jVlflvlllll6VvɖʶVfvφЖѦҶmFmn&nnnno.No^o~o oo o pp ?pO opp p p p p /q?q _qoqqnn6ooo!o.o$o_Wp'?pp*p q-pwq0_qqr !7r#O$gr&'r)*r,-r/0's27sGWsgws!"s$%s'(s*+s-.t0'17tFtVtftvttttttt ttuu'u7FVfv '7vFvVvfvvvvvvvvv v vww'w7wGwVwgwvw"ww%ww(ww+w w.xx1'x7xFWfv '7yogwxyxyxz'7Wgxyxyxy'yn{7{Og{{Oz{{{||'|7G|w7W'7}Wg}w}}?~Opo~~h~`~~X~P/?H_o@80X „ h!D&Rhq7r#Ȑ"(i$JVl򁃘2gt&Μ:0'P -jtJ2U)ԨR j*Vr@EËj)vlq$\)|ieͼ2wϣ6-t*bY[ꘫʖEvZnƥK]z x`Æ'fcb)|Zm9<]yI5`ՅY#vcai/EyK54QMOuWc'EKDNQ1ŞTaWD_}[ş\ ^E_ a Ơb6!d DY6azG~"L"Db& P*"U.Vc2x7∑;cI@$DdH*O9$`8ٔUJteZrȥJ^idNVm 'r^<ȥA )F"i6dnJg(I &~^TS2*Yg{J檁jJ(oʪh:멓륾ʩ‚jk*.ki2 l&J+^c@;tests/png/bug00381_2.gd0000644000000000000000000002343013153345533011607 0ustar # l,                #1B                 #1A            %&%      "0B        !( .          #     $/B                 !-C                *B                    '1@                     +A               !+B                      <                '0B           u IDATFED   %.C             ")B               *