Mail archive
alpine-aports

[alpine-aports] [PATCH] main/openjpeg: fix for CVE-2016-7163

From: Daniel Sabogal <dsabogalcc_at_gmail.com>
Date: Thu, 15 Sep 2016 12:53:23 -0400

---
 main/openjpeg/APKBUILD              | 18 +++++++++++++-----
 main/openjpeg/CVE-2016-7163-1.patch | 33 +++++++++++++++++++++++++++++++++
 main/openjpeg/CVE-2016-7163-2.patch | 26 ++++++++++++++++++++++++++
 3 files changed, 72 insertions(+), 5 deletions(-)
 create mode 100644 main/openjpeg/CVE-2016-7163-1.patch
 create mode 100644 main/openjpeg/CVE-2016-7163-2.patch
diff --git a/main/openjpeg/APKBUILD b/main/openjpeg/APKBUILD
index 65453d4..ca2b5f9 100644
--- a/main/openjpeg/APKBUILD
+++ b/main/openjpeg/APKBUILD
_at_@ -2,7 +2,7 @@
 # Maintainer: Francesco Colista <fcolista_at_alpinelinux.org>
 pkgname=openjpeg
 pkgver=2.1.1
-pkgrel=0
+pkgrel=1
 pkgdesc="Open-source implementation of JPEG2000 image codec"
 url="http://www.openjpeg.org/"
 arch="all"
_at_@ -12,7 +12,9 @@ depends_dev=""
 makedepends="$depends_dev libpng-dev tiff-dev lcms-dev doxygen cmake"
 install=""
 subpackages="$pkgname-dev $pkgname-tools"
-source="$pkgname-$pkgver.tar.gz::https://github.com/uclouvain/openjpeg/archive/v$pkgver.tar.gz"
+source="$pkgname-$pkgver.tar.gz::https://github.com/uclouvain/openjpeg/archive/v$pkgver.tar.gz
+	CVE-2016-7163-1.patch
+	CVE-2016-7163-2.patch"
 
 builddir="${srcdir}/$pkgname-$pkgver"
 
_at_@ -38,6 +40,12 @@ tools() {
 	mv "$pkgdir"/usr/bin "$subpkgdir"/usr/
 }
 
-md5sums="0cc4b2aee0a9b6e9e21b7abcd201a3ec  openjpeg-2.1.1.tar.gz"
-sha256sums="82c27f47fc7219e2ed5537ac69545bf15ed8c6ba8e6e1e529f89f7356506dbaa  openjpeg-2.1.1.tar.gz"
-sha512sums="c7c5cd95a3b8bc643207fecdfbffd45c3d91e48196455ae42061862aebcd558c3e508c39513285b8ebb4f57b7316116d15cc74c0b9cc3e31c2a7b70d3e5e2cdd  openjpeg-2.1.1.tar.gz"
+md5sums="0cc4b2aee0a9b6e9e21b7abcd201a3ec  openjpeg-2.1.1.tar.gz
+0c0e55bc80b5cd6b163fbc041e4e7aae  CVE-2016-7163-1.patch
+4edb6725ac44bd254f385a78ad4faa98  CVE-2016-7163-2.patch"
+sha256sums="82c27f47fc7219e2ed5537ac69545bf15ed8c6ba8e6e1e529f89f7356506dbaa  openjpeg-2.1.1.tar.gz
+65137ddd802e36893a52362da56de1b75c15c338f22e1c378c21288529008189  CVE-2016-7163-1.patch
+a36c73da751049410e94a9f4e56bce572ef5005ec8637401da9c02be0253d0ce  CVE-2016-7163-2.patch"
+sha512sums="c7c5cd95a3b8bc643207fecdfbffd45c3d91e48196455ae42061862aebcd558c3e508c39513285b8ebb4f57b7316116d15cc74c0b9cc3e31c2a7b70d3e5e2cdd  openjpeg-2.1.1.tar.gz
+3ab55487147464caf428c28f2a8585983a3a203bba731d83411b0bb0bfb8765992874aa42de3fddd8be5245897224f292c9853dc6103c5e16a3aa5bc1737b5be  CVE-2016-7163-1.patch
+d091d6ccbdbc7a2e2308815c5448f94a8d7f854c04c137d99f49bb26d142b790008388b730d9d83891842211ec56f1833a954e3bdfa3130ce7dcc1021a15c87e  CVE-2016-7163-2.patch"
diff --git a/main/openjpeg/CVE-2016-7163-1.patch b/main/openjpeg/CVE-2016-7163-1.patch
new file mode 100644
index 0000000..c7d277a
--- /dev/null
+++ b/main/openjpeg/CVE-2016-7163-1.patch
_at_@ -0,0 +1,33 @@
+From c16bc057ba3f125051c9966cf1f5b68a05681de4 Mon Sep 17 00:00:00 2001
+From: trylab <trylab_at_users.noreply.github.com>
+Date: Tue, 6 Sep 2016 13:55:49 +0800
+Subject: [PATCH] Fix an integer overflow issue (#809)
+
+Prevent an integer overflow issue in function opj_pi_create_decode of
+pi.c.
+---
+ src/lib/openjp2/pi.c | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/src/lib/openjp2/pi.c b/src/lib/openjp2/pi.c
+index cffad66..36e2ff0 100644
+--- a/src/lib/openjp2/pi.c
++++ b/src/lib/openjp2/pi.c
+_at_@ -1237,7 +1237,13 @@ opj_pi_iterator_t *opj_pi_create_decode(opj_image_t *p_image,
+ 	l_current_pi = l_pi;
+ 
+ 	/* memory allocation for include */
+-	l_current_pi->include = (OPJ_INT16*) opj_calloc((l_tcp->numlayers +1) * l_step_l, sizeof(OPJ_INT16));
++	/* prevent an integer overflow issue */
++	l_current_pi->include = 00;
++	if (l_step_l <= (SIZE_MAX / (l_tcp->numlayers + 1U)))
++	{
++		l_current_pi->include = (OPJ_INT16*) opj_calloc((l_tcp->numlayers +1) * l_step_l, sizeof(OPJ_INT16));
++	}
++
+ 	if
+ 		(!l_current_pi->include)
+ 	{
+-- 
+2.10.0
+
diff --git a/main/openjpeg/CVE-2016-7163-2.patch b/main/openjpeg/CVE-2016-7163-2.patch
new file mode 100644
index 0000000..71af3d7
--- /dev/null
+++ b/main/openjpeg/CVE-2016-7163-2.patch
_at_@ -0,0 +1,26 @@
+From ef01f18dfc6780b776d0674ed3e7415c6ef54d24 Mon Sep 17 00:00:00 2001
+From: Matthieu Darbois <mayeut_at_users.noreply.github.com>
+Date: Thu, 8 Sep 2016 07:34:46 +0200
+Subject: [PATCH] Cast to size_t before multiplication
+
+Need to cast to size_t before multiplication otherwise overflow check is useless.
+---
+ src/lib/openjp2/pi.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/lib/openjp2/pi.c b/src/lib/openjp2/pi.c
+index 36e2ff0..809b33d 100644
+--- a/src/lib/openjp2/pi.c
++++ b/src/lib/openjp2/pi.c
+_at_@ -1241,7 +1241,7 @@ opj_pi_iterator_t *opj_pi_create_decode(opj_image_t *p_image,
+ 	l_current_pi->include = 00;
+ 	if (l_step_l <= (SIZE_MAX / (l_tcp->numlayers + 1U)))
+ 	{
+-		l_current_pi->include = (OPJ_INT16*) opj_calloc((l_tcp->numlayers +1) * l_step_l, sizeof(OPJ_INT16));
++		l_current_pi->include = (OPJ_INT16*) opj_calloc((size_t)(l_tcp->numlayers + 1U) * l_step_l, sizeof(OPJ_INT16));
+ 	}
+ 
+ 	if
+-- 
+2.10.0
+
-- 
2.10.0
---
Unsubscribe:  alpine-aports+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-aports+help_at_lists.alpinelinux.org
---
Received on Thu Sep 15 2016 - 12:53:23 GMT