Wed Jul 11 09:07:21 2012 UTC ()
CVE-2012-3358:
A heap-based buffer overflow was found in the way OpenJPEG, an
open-source JPEG 2000 codec written in C language, performed parsing of
JPEG2000 having certain number of tiles and tilesizes. A remote
attacker could provide a specially crafted JPEG 2000 file, which when
opened in an application linked against openjpeg would lead to that
application crash, or, potentially arbitrary code execution with the
privileges of the user running the application.

http://code.google.com/p/openjpeg/source/detail?r=1727

Bump PKGREVISION.

pkglint cleanups while here.


(wiz)
diff -r1.1.1.1 -r1.2 pkgsrc/graphics/openjpeg/DESCR
diff -r1.2 -r1.3 pkgsrc/graphics/openjpeg/Makefile
diff -r1.2 -r1.3 pkgsrc/graphics/openjpeg/distinfo
diff -r0 -r1.1 pkgsrc/graphics/openjpeg/patches/patch-libopenjpeg_j2k.c

cvs diff -r1.1.1.1 -r1.2 pkgsrc/graphics/openjpeg/DESCR (expand / switch to unified diff)

--- pkgsrc/graphics/openjpeg/DESCR 2010/09/09 02:15:22 1.1.1.1
+++ pkgsrc/graphics/openjpeg/DESCR 2012/07/11 09:07:21 1.2
@@ -1,3 +1,3 @@ @@ -1,3 +1,3 @@
1The OpenJPEG library is an open-source JPEG 2000 codec written in C. It 1The OpenJPEG library is an open-source JPEG 2000 codec written in C. It
2has been developed in order to promote the use of JPEG 2000 and is 2has been developed in order to promote the use of JPEG 2000 and is
3licensed under a BSD license. 3licensed under a BSD license.

cvs diff -r1.2 -r1.3 pkgsrc/graphics/openjpeg/Makefile (expand / switch to unified diff)

--- pkgsrc/graphics/openjpeg/Makefile 2012/03/24 13:25:00 1.2
+++ pkgsrc/graphics/openjpeg/Makefile 2012/07/11 09:07:21 1.3
@@ -1,21 +1,22 @@ @@ -1,21 +1,22 @@
1# $NetBSD: Makefile,v 1.2 2012/03/24 13:25:00 drochner Exp $ 1# $NetBSD: Makefile,v 1.3 2012/07/11 09:07:21 wiz Exp $
2# 2#
3 3
4DISTNAME= openjpeg-1.5.0 4DISTNAME= openjpeg-1.5.0
 5PKGREVISION= 1
5CATEGORIES= graphics 6CATEGORIES= graphics
6MASTER_SITES= http://openjpeg.googlecode.com/files/ 7MASTER_SITES= http://openjpeg.googlecode.com/files/
7 8
8MAINTAINER= pkgsrc-users@NetBSD.org 9MAINTAINER= pkgsrc-users@NetBSD.org
9HOMEPAGE= http://www.openjpeg.org/ 10HOMEPAGE= http://www.openjpeg.org/
10COMMENT= JPEG 2000 library 11COMMENT= JPEG 2000 library
 12LICENSE= 2-clause-bsd
11 13
12PKG_DESTDIR_SUPPORT= user-destdir 14PKG_DESTDIR_SUPPORT= user-destdir
13LICENSE= 2-clause-bsd 
14 15
15GNU_CONFIGURE= yes 16GNU_CONFIGURE= yes
16CONFIGURE_ARGS+= --disable-doc 17CONFIGURE_ARGS+= --disable-doc
17USE_LIBTOOL= yes 18USE_LIBTOOL= yes
18 19
19CFLAGS+= -DHAVE_POSIX_MEMALIGN 20CFLAGS+= -DHAVE_POSIX_MEMALIGN
20 21
21.include "../../mk/bsd.pkg.mk" 22.include "../../mk/bsd.pkg.mk"

cvs diff -r1.2 -r1.3 pkgsrc/graphics/openjpeg/distinfo (expand / switch to unified diff)

--- pkgsrc/graphics/openjpeg/distinfo 2012/03/24 13:25:01 1.2
+++ pkgsrc/graphics/openjpeg/distinfo 2012/07/11 09:07:21 1.3
@@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
1$NetBSD: distinfo,v 1.2 2012/03/24 13:25:01 drochner Exp $ 1$NetBSD: distinfo,v 1.3 2012/07/11 09:07:21 wiz Exp $
2 2
3SHA1 (openjpeg-1.5.0.tar.gz) = dce705ae45f137e4698a8cf39d1fbf22bc434fa8 3SHA1 (openjpeg-1.5.0.tar.gz) = dce705ae45f137e4698a8cf39d1fbf22bc434fa8
4RMD160 (openjpeg-1.5.0.tar.gz) = ffa85dbb0a3ba1545bc6974f4950f466789c04ef 4RMD160 (openjpeg-1.5.0.tar.gz) = ffa85dbb0a3ba1545bc6974f4950f466789c04ef
5Size (openjpeg-1.5.0.tar.gz) = 2117572 bytes 5Size (openjpeg-1.5.0.tar.gz) = 2117572 bytes
6SHA1 (patch-aa) = 503b565958dc74a17b68f968a44c5c861d84b343 6SHA1 (patch-aa) = 503b565958dc74a17b68f968a44c5c861d84b343
 7SHA1 (patch-libopenjpeg_j2k.c) = 3ea7816b479dbba7822d20b187a6916e4d882e37

File Added: pkgsrc/graphics/openjpeg/patches/Attic/patch-libopenjpeg_j2k.c
$NetBSD: patch-libopenjpeg_j2k.c,v 1.1 2012/07/11 09:07:21 wiz Exp $

CVE-2012-3358:
A heap-based buffer overflow was found in the way OpenJPEG, an
open-source JPEG 2000 codec written in C language, performed parsing of
JPEG2000 having certain number of tiles and tilesizes. A remote
attacker could provide a specially crafted JPEG 2000 file, which when
opened in an application linked against openjpeg would lead to that
application crash, or, potentially arbitrary code execution with the
privileges of the user running the application.

http://code.google.com/p/openjpeg/source/detail?r=1727

--- libopenjpeg/j2k.c.orig	2012-02-07 10:49:55.000000000 +0000
+++ libopenjpeg/j2k.c
@@ -1269,7 +1269,7 @@ static void j2k_read_sot(opj_j2k_t *j2k)
 		static int backup_tileno = 0;
 
 		/* tileno is negative or larger than the number of tiles!!! */
-		if ((tileno < 0) || (tileno > (cp->tw * cp->th))) {
+		if ((tileno < 0) || (tileno >= (cp->tw * cp->th))) {
 			opj_event_msg(j2k->cinfo, EVT_ERROR,
 				"JPWL: bad tile number (%d out of a maximum of %d)\n",
 				tileno, (cp->tw * cp->th));
@@ -1286,8 +1286,18 @@ static void j2k_read_sot(opj_j2k_t *j2k)
 
 		/* keep your private count of tiles */
 		backup_tileno++;
-	};
+	}
+  else
 #endif /* USE_JPWL */
+  {
+    /* tileno is negative or larger than the number of tiles!!! */
+    if ((tileno < 0) || (tileno >= (cp->tw * cp->th))) {
+      opj_event_msg(j2k->cinfo, EVT_ERROR,
+        "JPWL: bad tile number (%d out of a maximum of %d)\n",
+        tileno, (cp->tw * cp->th));
+      return;
+    }
+  }
 	
 	if (cp->tileno_size == 0) {
 		cp->tileno[cp->tileno_size] = tileno;
@@ -1325,8 +1335,18 @@ static void j2k_read_sot(opj_j2k_t *j2k)
 				totlen);
 		}
 
-	};
+	}
+  else
 #endif /* USE_JPWL */
+  {
+    /* totlen is negative or larger than the bytes left!!! */
+    if ((totlen < 0) || (totlen > (cio_numbytesleft(cio) + 8))) {
+      opj_event_msg(j2k->cinfo, EVT_ERROR,
+        "JPWL: bad tile byte size (%d bytes against %d bytes left)\n",
+        totlen, cio_numbytesleft(cio) + 8);
+      return;
+    }
+  }
 
 	if (!totlen)
 		totlen = cio_numbytesleft(cio) + 8;