summaryrefslogtreecommitdiff
path: root/extra/libpng
diff options
context:
space:
mode:
authorroot <root@rshg054.dnsready.net>2013-05-07 00:36:35 -0700
committerroot <root@rshg054.dnsready.net>2013-05-07 00:36:35 -0700
commitda0a0d88caa1bf934ebf314ef86e15928dbb027b (patch)
treeb7c57ac9667de10c72390e0d81654fffbe47c42d /extra/libpng
parentffb692bf2696e7ebedd19bcd55ba253e21cb732d (diff)
Tue May 7 00:36:35 PDT 2013
Diffstat (limited to 'extra/libpng')
-rw-r--r--extra/libpng/0001-libpng16-Avoid-dereferencing-NULL-pointer-possibly-r.patch106
-rw-r--r--extra/libpng/0002-libpng16-Calculate-our-own-zlib-windowBits-when-deco.patch133
-rw-r--r--extra/libpng/PKGBUILD33
-rw-r--r--extra/libpng/adjust-apng-patch-for-libpng16-git-changes.patch19
4 files changed, 282 insertions, 9 deletions
diff --git a/extra/libpng/0001-libpng16-Avoid-dereferencing-NULL-pointer-possibly-r.patch b/extra/libpng/0001-libpng16-Avoid-dereferencing-NULL-pointer-possibly-r.patch
new file mode 100644
index 000000000..e67728051
--- /dev/null
+++ b/extra/libpng/0001-libpng16-Avoid-dereferencing-NULL-pointer-possibly-r.patch
@@ -0,0 +1,106 @@
+From 56d6bc2e8855d25e03816509a0137c3a70410ae6 Mon Sep 17 00:00:00 2001
+From: Glenn Randers-Pehrson <glennrp at users.sourceforge.net>
+Date: Mon, 29 Apr 2013 08:57:14 -0500
+Subject: [PATCH 06/10] [libpng16] Avoid dereferencing NULL pointer possibly
+ returned from
+
+png_create_write_struct() (Andrew Church).
+---
+ ANNOUNCE | 6 ++++--
+ CHANGES | 4 +++-
+ pngwrite.c | 65 +++++++++++++++++++++++++++++++-------------------------------
+ 3 files changed, 39 insertions(+), 36 deletions(-)
+
+ (foutrelis: pruned non-code changes to apply cleanly to libpng 1.6.2.)
+
+diff --git a/pngwrite.c b/pngwrite.c
+index 33924aa..b71a3d3 100644
+--- a/pngwrite.c
++++ b/pngwrite.c
+@@ -494,51 +494,50 @@ png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
+ png_structrp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
+ error_fn, warn_fn, mem_ptr, malloc_fn, free_fn);
+ #endif /* PNG_USER_MEM_SUPPORTED */
++ if (png_ptr != NULL)
++ {
++ /* Set the zlib control values to defaults; they can be overridden by the
++ * application after the struct has been created.
++ */
++ png_ptr->zbuffer_size = PNG_ZBUF_SIZE;
+
+- /* Set the zlib control values to defaults; they can be overridden by the
+- * application after the struct has been created.
+- */
+- png_ptr->zbuffer_size = PNG_ZBUF_SIZE;
+-
+- /* The 'zlib_strategy' setting is irrelevant because png_default_claim in
+- * pngwutil.c defaults it according to whether or not filters will be used,
+- * and ignores this setting.
+- */
+- png_ptr->zlib_strategy = PNG_Z_DEFAULT_STRATEGY;
+- png_ptr->zlib_level = PNG_Z_DEFAULT_COMPRESSION;
+- png_ptr->zlib_mem_level = 8;
+- png_ptr->zlib_window_bits = 15;
+- png_ptr->zlib_method = 8;
++ /* The 'zlib_strategy' setting is irrelevant because png_default_claim in
++ * pngwutil.c defaults it according to whether or not filters will be
++ * used, and ignores this setting.
++ */
++ png_ptr->zlib_strategy = PNG_Z_DEFAULT_STRATEGY;
++ png_ptr->zlib_level = PNG_Z_DEFAULT_COMPRESSION;
++ png_ptr->zlib_mem_level = 8;
++ png_ptr->zlib_window_bits = 15;
++ png_ptr->zlib_method = 8;
+
+ #ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
+- png_ptr->zlib_text_strategy = PNG_TEXT_Z_DEFAULT_STRATEGY;
+- png_ptr->zlib_text_level = PNG_TEXT_Z_DEFAULT_COMPRESSION;
+- png_ptr->zlib_text_mem_level = 8;
+- png_ptr->zlib_text_window_bits = 15;
+- png_ptr->zlib_text_method = 8;
++ png_ptr->zlib_text_strategy = PNG_TEXT_Z_DEFAULT_STRATEGY;
++ png_ptr->zlib_text_level = PNG_TEXT_Z_DEFAULT_COMPRESSION;
++ png_ptr->zlib_text_mem_level = 8;
++ png_ptr->zlib_text_window_bits = 15;
++ png_ptr->zlib_text_method = 8;
+ #endif /* PNG_WRITE_COMPRESSED_TEXT_SUPPORTED */
+
+- /* This is a highly dubious configuration option; by default it is off, but
+- * it may be appropriate for private builds that are testing extensions not
+- * conformant to the current specification, or of applications that must not
+- * fail to write at all costs!
+- */
+-# ifdef PNG_BENIGN_WRITE_ERRORS_SUPPORTED
++ /* This is a highly dubious configuration option; by default it is off,
++ * but it may be appropriate for private builds that are testing
++ * extensions not conformant to the current specification, or of
++ * applications that must not fail to write at all costs!
++ */
++#ifdef PNG_BENIGN_WRITE_ERRORS_SUPPORTED
+ png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN;
+ /* In stable builds only warn if an application error can be completely
+ * handled.
+ */
+-# endif
++#endif
+
+- /* App warnings are warnings in release (or release candidate) builds but
+- * are errors during development.
+- */
+-# if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
++ /* App warnings are warnings in release (or release candidate) builds but
++ * are errors during development.
++ */
++#if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
+ png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN;
+-# endif
++#endif
+
+- if (png_ptr != NULL)
+- {
+ /* TODO: delay this, it can be done in png_init_io() (if the app doesn't
+ * do it itself) avoiding setting the default function if it is not
+ * required.
+--
+1.8.2.2
+
diff --git a/extra/libpng/0002-libpng16-Calculate-our-own-zlib-windowBits-when-deco.patch b/extra/libpng/0002-libpng16-Calculate-our-own-zlib-windowBits-when-deco.patch
new file mode 100644
index 000000000..0a305c150
--- /dev/null
+++ b/extra/libpng/0002-libpng16-Calculate-our-own-zlib-windowBits-when-deco.patch
@@ -0,0 +1,133 @@
+From 127b08a265f99ce517ea31ec7988a91fc17da4d9 Mon Sep 17 00:00:00 2001
+From: Glenn Randers-Pehrson <glennrp at users.sourceforge.net>
+Date: Sun, 5 May 2013 22:13:47 -0500
+Subject: [PATCH 09/10] [libpng16] Calculate our own zlib windowBits when
+ decoding rather than
+
+trusting the CMF bytes in the PNG datastream.
+---
+ ANNOUNCE | 6 +++--
+ CHANGES | 5 +++-
+ pngrutil.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
+ 3 files changed, 88 insertions(+), 10 deletions(-)
+
+ (foutrelis: pruned non-code changes to apply cleanly to libpng 1.6.2.)
+
+diff --git a/pngrutil.c b/pngrutil.c
+index 01c3679..9c10e26 100644
+--- a/pngrutil.c
++++ b/pngrutil.c
+@@ -18,8 +18,6 @@
+
+ #ifdef PNG_READ_SUPPORTED
+
+-#define png_strtod(p,a,b) strtod(a,b)
+-
+ png_uint_32 PNGAPI
+ png_get_uint_31(png_const_structrp png_ptr, png_const_bytep buf)
+ {
+@@ -4165,6 +4163,75 @@ png_read_finish_row(png_structrp png_ptr)
+ }
+ #endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
+
++#ifdef PNG_READ_OPTIMIZE_WINDOWBITS_SUPPORTED
++/* This is the code to to select a windowBits value to match the smallest
++ * possible sliding window needed to contain the entire uncompressed image.
++ */
++static unsigned int
++required_window_bits(png_alloc_size_t data_size)
++{
++ unsigned int windowBits = 15;
++ if (data_size <= 16384) /* else windowBits must be 15 */
++ {
++ unsigned int half_z_window_size = 1U << (windowBits-1); /* 16384 */
++
++ do
++ {
++ half_z_window_size >>= 1;
++ --windowBits;
++ }
++ while (windowBits > 8 && data_size <= half_z_window_size);
++ }
++ return windowBits;
++}
++/* This is used below to find the size of an image to pass to png_deflate_claim,
++ * so it only needs to be accurate if the size is less than 16384 bytes (the
++ * point at which a lower LZ window size can be used.)
++ *
++ * To do: merge this with png_image_size() in pngwutil.c and put the result
++ * in png.c as a PNG_INTERNAL_FUNCTION.
++ */
++static png_alloc_size_t
++png_read_image_size(png_structrp png_ptr)
++{
++ /* Only return sizes up to the maximum of a png_uint_32, do this by limiting
++ * the width and height used to 15 bits.
++ */
++ png_uint_32 h = png_ptr->height;
++
++ if (png_ptr->rowbytes < 32768 && h < 32768)
++ {
++ if (png_ptr->interlaced)
++ {
++ /* Interlacing makes the image larger because of the replication of
++ * both the filter byte and the padding to a byte boundary.
++ */
++ png_uint_32 w = png_ptr->width;
++ unsigned int pd = png_ptr->pixel_depth;
++ png_alloc_size_t cb_base;
++ int pass;
++
++ for (cb_base=0, pass=0; pass<=6; ++pass)
++ {
++ png_uint_32 pw = PNG_PASS_COLS(w, pass);
++
++ if (pw > 0)
++ cb_base += (PNG_ROWBYTES(pd, pw)+1) * PNG_PASS_ROWS(h, pass);
++ }
++
++ return cb_base;
++ }
++
++ else
++ return (png_ptr->rowbytes+1) * h;
++ }
++
++ else
++ return 0xffffffffU;
++}
++
++#endif /* PNG_READ_OPTIMIZE_WINDOWBITS_SUPPORTED */
++
+ void /* PRIVATE */
+ png_read_start_row(png_structrp png_ptr)
+ {
+@@ -4449,14 +4516,20 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
+ png_free(png_ptr, buffer);
+ }
+
+- /* Finally claim the zstream for the inflate of the IDAT data, use the bits
+- * value from the stream (note that this will result in a fatal error if the
+- * IDAT stream has a bogus deflate header window_bits value, but this should
+- * not be happening any longer!)
++ /* Finally claim the zstream for the inflate of the IDAT data, using the
++ * windowBts predicted from the uncompressed data size, not the value from
++ * the stream. If READ_OPTIMIZE_WINDOWBITS_SUPPORTED is not defined, then
++ * simply use a 32kbyte window (windowBits=15).
+ */
+- if (png_inflate_claim(png_ptr, png_IDAT, 0) != Z_OK)
++#ifdef PNG_READ_OPTIMIZE_WINDOWBITS_SUPPORTED
++ if (png_inflate_claim(png_ptr, png_IDAT,
++ required_window_bits(png_read_image_size(png_ptr))) != Z_OK)
++#else
++ if (png_inflate_claim(png_ptr, png_IDAT, 15) != Z_OK)
++#endif
+ png_error(png_ptr, png_ptr->zstream.msg);
+
+ png_ptr->flags |= PNG_FLAG_ROW_INIT;
+ }
++
+ #endif /* PNG_READ_SUPPORTED */
+--
+1.8.2.2
+
diff --git a/extra/libpng/PKGBUILD b/extra/libpng/PKGBUILD
index 40e363a68..ab48303fc 100644
--- a/extra/libpng/PKGBUILD
+++ b/extra/libpng/PKGBUILD
@@ -1,13 +1,13 @@
-# $Id: PKGBUILD 182372 2013-04-09 18:14:06Z ioni $
+# $Id: PKGBUILD 184406 2013-05-06 19:38:28Z foutrelis $
# Maintainer: Jan de Groot <jgc@archlinux.org>
# Contributor: dorphell <dorphell@archlinux.org>
# Contributor: Travis Willard <travis@archlinux.org>
# Contributor: Douglas Soares de Andrade <douglas@archlinux.org>
pkgname=libpng
-pkgver=1.5.15
-_apngver=1.5.15
-pkgrel=1
+pkgver=1.6.2
+_apngver=1.6.2
+pkgrel=3
pkgdesc="A collection of routines used to create PNG format graphics files"
arch=('i686' 'x86_64')
url="http://www.libpng.org/pub/png/libpng.html"
@@ -15,16 +15,31 @@ license=('custom')
depends=('zlib' 'sh')
options=('!libtool')
source=("http://downloads.sourceforge.net/sourceforge/$pkgname/$pkgname-$pkgver.tar.xz"
- "http://downloads.sourceforge.net/sourceforge/libpng-apng/libpng-$_apngver-apng.patch.gz")
-md5sums=('e3122e7b5b5c36c034a4624c65f8a9d8'
- '3ae9ea7e4bd201f0b25e25cd6049b094')
+ "http://downloads.sourceforge.net/sourceforge/libpng-apng/libpng-$_apngver-apng.patch.gz"
+ 0001-libpng16-Avoid-dereferencing-NULL-pointer-possibly-r.patch
+ 0002-libpng16-Calculate-our-own-zlib-windowBits-when-deco.patch
+ adjust-apng-patch-for-libpng16-git-changes.patch)
+md5sums=('9d838f6fca9948a9f360a0cc1b516d5f'
+ '7d0c9f4b9a7f45dd5d1088e54b623c98'
+ '59b83234f60a7d1d179d9b0b6a0ebc01'
+ 'b1f7922b6678305bdb7c23d5bd1763f3'
+ 'f87704c3fb6d29f09b52178e89a42e2e')
-build() {
+prepare() {
cd $pkgname-$pkgver
+ # Add fixes from libpng16 branch
+ patch -Np1 -i ../0001-libpng16-Avoid-dereferencing-NULL-pointer-possibly-r.patch
+ patch -Np1 -i ../0002-libpng16-Calculate-our-own-zlib-windowBits-when-deco.patch
+
# Add animated PNG (apng) support
# see http://sourceforge.net/projects/libpng-apng/
- patch -p1 -i ../libpng-$_apngver-apng.patch
+ patch -d .. -Np0 -i adjust-apng-patch-for-libpng16-git-changes.patch
+ patch -Np1 -i ../libpng-$_apngver-apng.patch
+}
+
+build() {
+ cd $pkgname-$pkgver
./configure --prefix=/usr
make
diff --git a/extra/libpng/adjust-apng-patch-for-libpng16-git-changes.patch b/extra/libpng/adjust-apng-patch-for-libpng16-git-changes.patch
new file mode 100644
index 000000000..26ac1c1cf
--- /dev/null
+++ b/extra/libpng/adjust-apng-patch-for-libpng16-git-changes.patch
@@ -0,0 +1,19 @@
+--- libpng-1.6.2-apng.patch.orig 2013-05-06 12:09:16.000000000 +0300
++++ libpng-1.6.2-apng.patch 2013-05-06 12:12:14.000000000 +0300
+@@ -1034,7 +1034,7 @@ diff -Naru libpng-1.6.2.org/pngrutil.c l
+
+ if (png_ptr->zstream.avail_in > 0 || png_ptr->idat_size > 0)
+ png_chunk_benign_error(png_ptr, "Extra compressed data");
+-@@ -4459,4 +4671,80 @@
++@@ -4459,5 +4671,81 @@
+
+ png_ptr->flags |= PNG_FLAG_ROW_INIT;
+ }
+@@ -1114,6 +1114,7 @@ diff -Naru libpng-1.6.2.org/pngrutil.c l
+ +}
+ +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
+ +#endif /* PNG_READ_APNG_SUPPORTED */
++
+ #endif /* PNG_READ_SUPPORTED */
+ diff -Naru libpng-1.6.2.org/pngset.c libpng-1.6.2/pngset.c
+ --- libpng-1.6.2.org/pngset.c 2013-04-29 17:31:42.000000000 +0900