pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/graphics/tiff Apply fix for integer overflows in vario...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/2edd328a5700
branches:  trunk
changeset: 562018:2edd328a5700
user:      tron <tron%pkgsrc.org@localhost>
date:      Sun Jul 19 11:45:09 2009 +0000

description:
Apply fix for integer overflows in various inter-color space conversion
tools taken from MapTools Bugzilla. This fixes CVE-2009-2347.

diffstat:

 graphics/tiff/Makefile         |    4 +-
 graphics/tiff/distinfo         |    4 +-
 graphics/tiff/patches/patch-ca |   47 +++++++++++++++
 graphics/tiff/patches/patch-cb |  126 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 178 insertions(+), 3 deletions(-)

diffs (209 lines):

diff -r a0a79722feaf -r 2edd328a5700 graphics/tiff/Makefile
--- a/graphics/tiff/Makefile    Sun Jul 19 11:35:41 2009 +0000
+++ b/graphics/tiff/Makefile    Sun Jul 19 11:45:09 2009 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.87 2009/06/22 14:54:44 drochner Exp $
+# $NetBSD: Makefile,v 1.88 2009/07/19 11:45:09 tron Exp $
 
 DISTNAME=      tiff-3.8.2
-PKGREVISION=   5
+PKGREVISION=   6
 CATEGORIES=    graphics
 MASTER_SITES=  ftp://ftp.remotesensing.org/pub/libtiff/ \
                http://libtiff.maptools.org/dl/
diff -r a0a79722feaf -r 2edd328a5700 graphics/tiff/distinfo
--- a/graphics/tiff/distinfo    Sun Jul 19 11:35:41 2009 +0000
+++ b/graphics/tiff/distinfo    Sun Jul 19 11:45:09 2009 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.42 2009/06/22 14:54:44 drochner Exp $
+$NetBSD: distinfo,v 1.43 2009/07/19 11:45:09 tron Exp $
 
 SHA1 (tiff-3.8.2.tar.gz) = 549e67b6a15b42bfcd72fe17cda7c9a198a393eb
 RMD160 (tiff-3.8.2.tar.gz) = 1b4d825e3be08764e953fc58246d0c25ab4dd17d
@@ -16,3 +16,5 @@
 SHA1 (patch-ba) = d4bd9c67a9bf2be93286f8268ac520c4b88ba3ae
 SHA1 (patch-bb) = cbc7feda655a02809de55be6470cc25cda942a08
 SHA1 (patch-bc) = 9baa1c138cd3cb6366ae3e638518b94dfea172cc
+SHA1 (patch-ca) = 3c90d9735f0586632db05ceb50b336cbfdf279b6
+SHA1 (patch-cb) = 349c8764091d69f5eca84588837022d218b2165c
diff -r a0a79722feaf -r 2edd328a5700 graphics/tiff/patches/patch-ca
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics/tiff/patches/patch-ca    Sun Jul 19 11:45:09 2009 +0000
@@ -0,0 +1,47 @@
+$NetBSD: patch-ca,v 1.1 2009/07/19 11:45:09 tron Exp $
+
+Patch for CVE-2009-2347, taken from here:
+
+http://bugzilla.maptools.org/show_bug.cgi?id=2079
+
+--- tools/rgb2ycbcr.c.orig     2004-09-03 08:57:13.000000000 +0100
++++ tools/rgb2ycbcr.c  2009-07-19 12:39:06.000000000 +0100
+@@ -202,6 +202,17 @@
+ #undef LumaBlue
+ #undef V2Code
+ 
++static tsize_t
++multiply(tsize_t m1, tsize_t m2)
++{
++    tsize_t prod = m1 * m2;
++
++    if (m1 && prod / m1 != m2)
++        prod = 0;             /* overflow */
++
++    return prod;
++}
++
+ /*
+  * Convert a strip of RGB data to YCbCr and
+  * sample to generate the output data.
+@@ -278,10 +289,19 @@
+       float floatv;
+       char *stringv;
+       uint32 longv;
++      tsize_t raster_size;
+ 
+       TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width);
+       TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height);
+-      raster = (uint32*)_TIFFmalloc(width * height * sizeof (uint32));
++
++      raster_size = multiply(multiply(width, height), sizeof (uint32));
++      if (!raster_size) {
++              TIFFError(TIFFFileName(in),
++                        "Can't allocate buffer for raster of size %lux%lu",
++                        (unsigned long) width, (unsigned long) height);
++              return (0);
++      }
++      raster = (uint32*)_TIFFmalloc(raster_size);
+       if (raster == 0) {
+               TIFFError(TIFFFileName(in), "No space for raster buffer");
+               return (0);
diff -r a0a79722feaf -r 2edd328a5700 graphics/tiff/patches/patch-cb
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics/tiff/patches/patch-cb    Sun Jul 19 11:45:09 2009 +0000
@@ -0,0 +1,126 @@
+$NetBSD: patch-cb,v 1.1 2009/07/19 11:45:09 tron Exp $
+
+Patch for CVE-2009-2347, taken from here:
+
+http://bugzilla.maptools.org/show_bug.cgi?id=2079
+
+--- tools/tiff2rgba.c.orig     2004-11-07 11:08:37.000000000 +0000
++++ tools/tiff2rgba.c  2009-07-19 12:39:06.000000000 +0100
+@@ -124,6 +124,17 @@
+     return (0);
+ }
+ 
++static tsize_t
++multiply(tsize_t m1, tsize_t m2)
++{
++    tsize_t prod = m1 * m2;
++
++    if (m1 && prod / m1 != m2)
++        prod = 0;             /* overflow */
++
++    return prod;
++}
++
+ static int
+ cvt_by_tile( TIFF *in, TIFF *out )
+ 
+@@ -133,6 +144,7 @@
+     uint32  tile_width, tile_height;
+     uint32  row, col;
+     uint32  *wrk_line;
++    tsize_t raster_size;
+     int           ok = 1;
+ 
+     TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width);
+@@ -150,7 +162,14 @@
+     /*
+      * Allocate tile buffer
+      */
+-    raster = (uint32*)_TIFFmalloc(tile_width * tile_height * sizeof (uint32));
++    raster_size = multiply(multiply(tile_width, tile_height), sizeof (uint32));
++    if (!raster_size) {
++      TIFFError(TIFFFileName(in),
++                "Can't allocate buffer for raster of size %lux%lu",
++                (unsigned long) tile_width, (unsigned long) tile_height);
++      return (0);
++    }
++    raster = (uint32*)_TIFFmalloc(raster_size);
+     if (raster == 0) {
+         TIFFError(TIFFFileName(in), "No space for raster buffer");
+         return (0);
+@@ -158,7 +177,7 @@
+ 
+     /*
+      * Allocate a scanline buffer for swapping during the vertical
+-     * mirroring pass.
++     * mirroring pass.  (Request can't overflow given prior checks.)
+      */
+     wrk_line = (uint32*)_TIFFmalloc(tile_width * sizeof (uint32));
+     if (!wrk_line) {
+@@ -226,6 +245,7 @@
+     uint32  width, height;            /* image width & height */
+     uint32  row;
+     uint32  *wrk_line;
++    tsize_t raster_size;
+     int           ok = 1;
+ 
+     TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width);
+@@ -241,7 +261,14 @@
+     /*
+      * Allocate strip buffer
+      */
+-    raster = (uint32*)_TIFFmalloc(width * rowsperstrip * sizeof (uint32));
++    raster_size = multiply(multiply(width, rowsperstrip), sizeof (uint32));
++    if (!raster_size) {
++      TIFFError(TIFFFileName(in),
++                "Can't allocate buffer for raster of size %lux%lu",
++                (unsigned long) width, (unsigned long) rowsperstrip);
++      return (0);
++    }
++    raster = (uint32*)_TIFFmalloc(raster_size);
+     if (raster == 0) {
+         TIFFError(TIFFFileName(in), "No space for raster buffer");
+         return (0);
+@@ -249,7 +276,7 @@
+ 
+     /*
+      * Allocate a scanline buffer for swapping during the vertical
+-     * mirroring pass.
++     * mirroring pass.  (Request can't overflow given prior checks.)
+      */
+     wrk_line = (uint32*)_TIFFmalloc(width * sizeof (uint32));
+     if (!wrk_line) {
+@@ -328,14 +355,22 @@
+     uint32* raster;                   /* retrieve RGBA image */
+     uint32  width, height;            /* image width & height */
+     uint32  row;
+-        
++    tsize_t raster_size;
++
+     TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width);
+     TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height);
+ 
+     rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip);
+     TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
+ 
+-    raster = (uint32*)_TIFFmalloc(width * height * sizeof (uint32));
++    raster_size = multiply(multiply(width, height), sizeof (uint32));
++    if (!raster_size) {
++      TIFFError(TIFFFileName(in),
++                "Can't allocate buffer for raster of size %lux%lu",
++                (unsigned long) width, (unsigned long) height);
++      return (0);
++    }
++    raster = (uint32*)_TIFFmalloc(raster_size);
+     if (raster == 0) {
+         TIFFError(TIFFFileName(in), "No space for raster buffer");
+         return (0);
+@@ -353,7 +388,7 @@
+     */
+     if( no_alpha )
+     {
+-        int   pixel_count = width * height;
++        tsize_t  pixel_count = (tsize_t) width * (tsize_t) height;
+         unsigned char *src, *dst;
+ 
+         src = (unsigned char *) raster;



Home | Main Index | Thread Index | Old Index