Subject: [alpine-aports] [PATCH] main/curl: security upgrade to 7.50.3 (CVE-2016-7167)

From: Daniel Sabogal <[email-masked]>
Date: Thu, 15 Sep 2016 12:53:22 -0400

---
 main/curl/APKBUILD | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/main/curl/APKBUILD b/main/curl/APKBUILD
index d81ec1a..a92406b 100644
--- a/main/curl/APKBUILD
+++ b/main/curl/APKBUILD
@@ -2,7 +2,7 @@
 # Contributor: Łukasz Jendrysik <[email-masked]>
 # Maintainer: Natanael Copa <[email-masked]>
 pkgname=curl
-pkgver=7.50.2
+pkgver=7.50.3
 pkgrel=0
 pkgdesc="An URL retrival utility and library"
 url="http://curl.haxx.se"
@@ -15,6 +15,8 @@ source="http://curl.haxx.se/download/$pkgname-$pkgver.tar.bz2"
 subpackages="$pkgname-doc $pkgname-dev libcurl"
 
 # secfixes:
+#   7.50.3:
+#     - CVE-2016-7167
 #   7.50.2:
 #     - CVE-2016-7141
 #   7.50.1:
@@ -54,6 +56,6 @@ libcurl() {
 	mv "$pkgdir"/usr/lib "$subpkgdir"/usr
 }
 
-md5sums="6e161179f7af4b9f8b6ea21420132719  curl-7.50.2.tar.bz2"
-sha256sums="0c72105df4e9575d68bcf43aea1751056c1d29b1040df6194a49c5ac08f8e233  curl-7.50.2.tar.bz2"
-sha512sums="5db4fba920f1627e545ddf774ceaafe3afce43c85aaa8aa7842337fe6cbc031aa597d9d80457c5d52bc7a0c218de30bb29802383e1d81e3f220186212dade342  curl-7.50.2.tar.bz2"
+md5sums="bd177fd6deecce00cfa7b5916d831c5e  curl-7.50.3.tar.bz2"
+sha256sums="7b7347d976661d02c84a1f4d6daf40dee377efdc45b9e2c77dedb8acf140d8ec  curl-7.50.3.tar.bz2"
+sha512sums="59012f0d9abd38d00e0b2db0cd5d8b513c08000354d31e7318007b688dc1eb71a0ac71a13acd40b0becc6199299091697b448d2e6895f90e103a23cd23f7f621  curl-7.50.3.tar.bz2"
-- 
2.10.0

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Daniel Sabogal <[email-masked]>
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
@@ -2,7 +2,7 @@
 # Maintainer: Francesco Colista <[email-masked]>
 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"
@@ -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"
 
@@ -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
@@ -0,0 +1,33 @@
+From c16bc057ba3f125051c9966cf1f5b68a05681de4 Mon Sep 17 00:00:00 2001
+From: trylab <[email-masked]>
+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
+@@ -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
@@ -0,0 +1,26 @@
+From ef01f18dfc6780b776d0674ed3e7415c6ef54d24 Mon Sep 17 00:00:00 2001
+From: Matthieu Darbois <[email-masked]>
+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
+@@ -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

---