Subject: [alpine-aports] [PATCH] main/mupdf: upgrade to 1.11

From: Daniel Sabogal <[email-masked]>
Date: Tue, 11 Apr 2017 13:26:36 -0400

Move muraster to mupdf-tools
---
 main/mupdf/APKBUILD            | 15 +++----
 main/mupdf/CVE-2017-5896.patch | 51 -----------------------
 main/mupdf/CVE-2017-5991.patch | 91 ------------------------------------------
 main/mupdf/openjpeg-2.1.patch  | 17 ++++----
 main/mupdf/shared-lib.patch    | 36 ++++++++---------
 5 files changed, 31 insertions(+), 179 deletions(-)
 delete mode 100644 main/mupdf/CVE-2017-5896.patch
 delete mode 100644 main/mupdf/CVE-2017-5991.patch

diff --git a/main/mupdf/APKBUILD b/main/mupdf/APKBUILD
index 4313969bc9..b98896dd7c 100644
--- a/main/mupdf/APKBUILD
+++ b/main/mupdf/APKBUILD
@@ -2,8 +2,8 @@
 # Contributor: Michael Zhou <[email-masked]>
 # Maintainer: Daniel Sabogal <[email-masked]>
 pkgname=mupdf
-pkgver=1.10a
-pkgrel=2
+pkgver=1.11
+pkgrel=0
 pkgdesc="A lightweight PDF and XPS viewer"
 url="http://mupdf.com"
 arch="all"
@@ -17,8 +17,6 @@ options="!check"
 source="http://mupdf.com/downloads/archive/$pkgname-$pkgver-source.tar.gz
 	shared-lib.patch
 	openjpeg-2.1.patch
-	CVE-2017-5896.patch
-	CVE-2017-5991.patch
 	"
 
 # secfixes:
@@ -80,11 +78,10 @@ _tools() {
 	mkdir -p "$subpkgdir"/usr/bin
 	mv "$pkgdir"/usr/bin/mutool \
 		"$pkgdir"/usr/bin/mujstest \
+		"$pkgdir"/usr/bin/muraster \
 		"$subpkgdir"/usr/bin/ || return 1
 }
 
-sha512sums="8c735963364985e74ceb38242afae555a3d2ee7c69abe3fe5c485e8613a83d996a58f231cb689a156019d431fa67d565503247d010b0a404054850483aed9fec  mupdf-1.10a-source.tar.gz
-bc38cc6935ed1c5941773e0671bea25d33897c1018c30f11ff3a1ec1e583276597f521b9e526f9bd38a6f9a1e76aa3e52782995ded72a618d07811abcd7ca734  shared-lib.patch
-bfb509c529e26c3d2dc827298ce3a6083640fbe3fd7491560ffb1e8f86d62bbd4a5d52721079caef8a38d6f332132b581859276000b397f9512673eedb0315a7  openjpeg-2.1.patch
-e9f29b909e016967fc9e6ca6723d63aecfea5c8aeadbd923bbf8a0fa1f4b0e16bd4eedac178bbf5fa359e47a55aa307b6581c6ce45b177ee12430f41c0b49cd7  CVE-2017-5896.patch
-b65a9dce7ba239be788d144c27edb7528ebcf08ead4defe887a08d7879cf72ca3b172a9a33ec3f9426743f45ecb9aac17baf1b526bf5f880beb00bdd84bdc42a  CVE-2017-5991.patch"
+sha512sums="501670f540e298a8126806ebbd9db8b29866f663b7bbf26c9ade1933e42f0c00ad410b9d93f3ddbfb3e45c38722869095de28d832fe3fb3703c55cc9a01dbf63  mupdf-1.11-source.tar.gz
+b3ddbc22da894a8b9a0fa0c93711e2052b5d2ca29497473b6e15ffbae52faaafff9238619680de474c455ebd073c2d29ead4ff5d962fddb99f7ced27057fa77f  shared-lib.patch
+f8283db9a510527e84afeeb6eea89948161899c149a559c4a699c533445b42f30e5bf520616ca69d7feb554529ad494a60c276a1eecc915723ec0f264bbc0ed0  openjpeg-2.1.patch"
diff --git a/main/mupdf/CVE-2017-5896.patch b/main/mupdf/CVE-2017-5896.patch
deleted file mode 100644
index a68715ac31..0000000000
--- a/main/mupdf/CVE-2017-5896.patch
+++ /dev/null
@@ -1,51 +0,0 @@
-From 2c4e5867ee699b1081527bc6c6ea0e99a35a5c27 Mon Sep 17 00:00:00 2001
-From: Robin Watts <[email-masked]>
-Date: Thu, 9 Feb 2017 07:12:16 -0800
-Subject: [PATCH] bug 697515: Fix out of bounds read in fz_subsample_pixmap
-
-Pointer arithmetic for final special case was going wrong.
----
- source/fitz/pixmap.c | 6 ++++--
- 1 file changed, 4 insertions(+), 2 deletions(-)
-
-diff --git a/source/fitz/pixmap.c b/source/fitz/pixmap.c
-index a831712..f1291dc 100644
---- a/source/fitz/pixmap.c
-+++ b/source/fitz/pixmap.c
-@@ -1104,6 +1104,7 @@ fz_subsample_pixmap_ARM(unsigned char *ptr, int w, int h, int f, int factor,
- 	"@STACK:r1,<9>,factor,n,fwd,back,back2,fwd2,divX,back4,fwd4,fwd3,divY,back5,divXY\n"
- 	"ldr	r4, [r13,#4*22]		@ r4 = divXY			\n"
- 	"ldr	r5, [r13,#4*11]		@ for (nn = n; nn > 0; n--) {	\n"
-+	"ldr	r8, [r13,#4*17]		@ r8 = back4			\n"
- 	"18:				@				\n"
- 	"mov	r14,#0			@ r14= v = 0			\n"
- 	"sub	r5, r5, r1, LSL #8	@ for (xx = x; xx > 0; x--) {	\n"
-@@ -1120,7 +1121,7 @@ fz_subsample_pixmap_ARM(unsigned char *ptr, int w, int h, int f, int factor,
- 	"mul	r14,r4, r14		@ r14= v *= divX		\n"
- 	"mov	r14,r14,LSR #16		@ r14= v >>= 16			\n"
- 	"strb	r14,[r9], #1		@ *d++ = r14			\n"
--	"sub	r0, r0, r8		@ s -= back2			\n"
-+	"sub	r0, r0, r8		@ s -= back4			\n"
- 	"subs	r5, r5, #1		@ n--				\n"
- 	"bgt	18b			@ }				\n"
- 	"21:				@				\n"
-@@ -1249,6 +1250,7 @@ fz_subsample_pixmap(fz_context *ctx, fz_pixmap *tile, int factor)
- 		x += f;
- 		if (x > 0)
- 		{
-+			int back4 = x * n - 1;
- 			div = x * y;
- 			for (nn = n; nn > 0; nn--)
- 			{
-@@ -1263,7 +1265,7 @@ fz_subsample_pixmap(fz_context *ctx, fz_pixmap *tile, int factor)
- 					s -= back5;
- 				}
- 				*d++ = v / div;
--				s -= back2;
-+				s -= back4;
- 			}
- 		}
- 	}
--- 
-2.9.1
-
diff --git a/main/mupdf/CVE-2017-5991.patch b/main/mupdf/CVE-2017-5991.patch
deleted file mode 100644
index d19d2e6c4e..0000000000
--- a/main/mupdf/CVE-2017-5991.patch
+++ /dev/null
@@ -1,91 +0,0 @@
-From 1912de5f08e90af1d9d0a9791f58ba3afdb9d465 Mon Sep 17 00:00:00 2001
-From: Robin Watts <[email-masked]>
-Date: Thu, 9 Feb 2017 15:49:15 +0000
-Subject: [PATCH] Bug 697500: Fix NULL ptr access.
-
-Cope better with errors during rendering - avoid letting the
-gstate stack get out of sync.
-
-This avoids us ever getting into the situation of popping
-a clip when we should be popping a mask or a group. This was
-causing an unexpected case in the painting.
----
- source/pdf/pdf-op-run.c | 26 ++++++++++++++++++--------
- 1 file changed, 18 insertions(+), 8 deletions(-)
-
-diff --git a/source/pdf/pdf-op-run.c b/source/pdf/pdf-op-run.c
-index a3ea895..f1eac8d 100644
---- a/source/pdf/pdf-op-run.c
-+++ b/source/pdf/pdf-op-run.c
-@@ -1213,6 +1213,7 @@ pdf_run_xobject(fz_context *ctx, pdf_run_processor *proc, pdf_xobject *xobj, pdf
- 	pdf_run_processor *pr = (pdf_run_processor *)proc;
- 	pdf_gstate *gstate = NULL;
- 	int oldtop = 0;
-+	int oldbot = -1;
- 	fz_matrix local_transform = *transform;
- 	softmask_save softmask = { NULL };
- 	int gparent_save;
-@@ -1232,16 +1233,17 @@ pdf_run_xobject(fz_context *ctx, pdf_run_processor *proc, pdf_xobject *xobj, pdf
- 	fz_var(cleanup_state);
- 	fz_var(gstate);
- 	fz_var(oldtop);
-+	fz_var(oldbot);
- 
- 	gparent_save = pr->gparent;
- 	pr->gparent = pr->gtop;
-+	oldtop = pr->gtop;
- 
- 	fz_try(ctx)
- 	{
- 		pdf_gsave(ctx, pr);
- 
- 		gstate = pr->gstate + pr->gtop;
--		oldtop = pr->gtop;
- 
- 		pdf_xobject_bbox(ctx, xobj, &xobj_bbox);
- 		pdf_xobject_matrix(ctx, xobj, &xobj_matrix);
-@@ -1302,12 +1304,25 @@ pdf_run_xobject(fz_context *ctx, pdf_run_processor *proc, pdf_xobject *xobj, pdf
- 
- 		doc = pdf_get_bound_document(ctx, xobj->obj);
- 
-+		oldbot = pr->gbot;
-+		pr->gbot = pr->gtop;
-+
- 		pdf_process_contents(ctx, (pdf_processor*)pr, doc, resources, xobj->obj, NULL);
- 	}
- 	fz_always(ctx)
- 	{
-+		/* Undo any gstate mismatches due to the pdf_process_contents call */
-+		if (oldbot != -1)
-+		{
-+			while (pr->gtop > pr->gbot)
-+			{
-+				pdf_grestore(ctx, pr);
-+			}
-+			pr->gbot = oldbot;
-+		}
-+
- 		if (cleanup_state >= 3)
--			pdf_grestore(ctx, pr); /* Remove the clippath */
-+			pdf_grestore(ctx, pr); /* Remove the state we pushed for the clippath */
- 
- 		/* wrap up transparency stacks */
- 		if (transparency)
-@@ -1341,13 +1356,8 @@ pdf_run_xobject(fz_context *ctx, pdf_run_processor *proc, pdf_xobject *xobj, pdf
- 		pr->gstate[pr->gparent].ctm = gparent_save_ctm;
- 		pr->gparent = gparent_save;
- 
--		if (gstate)
--		{
--			while (oldtop < pr->gtop)
--				pdf_grestore(ctx, pr);
--
-+		while (oldtop < pr->gtop)
- 			pdf_grestore(ctx, pr);
--		}
- 
- 		pdf_unmark_obj(ctx, xobj->obj);
- 	}
--- 
-2.9.1
-
diff --git a/main/mupdf/openjpeg-2.1.patch b/main/mupdf/openjpeg-2.1.patch
index 2e14db0f44..3181c461f3 100644
--- a/main/mupdf/openjpeg-2.1.patch
+++ b/main/mupdf/openjpeg-2.1.patch
@@ -1,17 +1,14 @@
---- mupdf-1.10-source/source/fitz/load-jpx.c.orig
-+++ mupdf-1.10-source/source/fitz/load-jpx.c
-@@ -481,14 +481,6 @@
+--- mupdf-1.11-source/source/fitz/load-jpx.c.orig
++++ mupdf-1.11-source/source/fitz/load-jpx.c
+@@ -444,11 +444,6 @@
  
  #else /* HAVE_LURATECH */
  
--/* Without the definition of OPJ_STATIC, compilation fails on windows
-- * due to the use of __stdcall. We believe it is required on some
-- * linux toolchains too. */
 -#define OPJ_STATIC
--#ifndef _MSC_VER
+-#define OPJ_HAVE_INTTYPES_H
+-#if !defined(_WIN32) && !defined(_WIN64)
 -#define OPJ_HAVE_STDINT_H
 -#endif
--
- #include <openjpeg.h>
+ #define USE_JPIP
  
- /* OpenJPEG does not provide a safe mechanism to intercept
+ #include <openjpeg.h>
diff --git a/main/mupdf/shared-lib.patch b/main/mupdf/shared-lib.patch
index d0e364d247..a73d885364 100644
--- a/main/mupdf/shared-lib.patch
+++ b/main/mupdf/shared-lib.patch
@@ -1,22 +1,32 @@
---- mupdf-1.9a-source/Makefile.orig
-+++ mupdf-1.9a-source/Makefile
-@@ -16,6 +16,7 @@
+--- mupdf-1.11-source/Makefile.orig
++++ mupdf-1.11-source/Makefile
+@@ -15,6 +15,7 @@
  # XCFLAGS or XLIBS instead. Make ignores any lines in the makefile that
  # set a variable that was set on the command line.
- CFLAGS += $(XCFLAGS) -Iinclude -I$(GEN)
+ CFLAGS += $(XCFLAGS) -Iinclude -Igenerated
 +CFLAGS += -fPIC
  LIBS += $(XLIBS) -lm
  
  LIBS += $(FREETYPE_LIBS)
-@@ -52,6 +53,7 @@
+@@ -73,6 +74,7 @@
  CXX_CMD = $(QUIET_CXX) $(CXX) $(CFLAGS) -o $@ -c $<
  AR_CMD = $(QUIET_AR) $(AR) cr $@ $^
  LINK_CMD = $(QUIET_LINK) $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
 +LINK_SHARED_CMD = $(QUIET_LINK) $(CC) $(LDFLAGS) -shared -Wl,-soname,$(notdir $@) -o $@ $^ $(LIBS)
  MKDIR_CMD = $(QUIET_MKDIR) mkdir -p $@
  RM_CMD = $(QUIET_RM) rm -f $@
+ TAGS_CMD = $(QUIET_TAGS) ctags $^
+@@ -88,6 +90,9 @@
+ 	$(AR_CMD)
+ 	$(RANLIB_CMD)
+ 
++$(OUT)/%.so.0: $(OUT)/%.a
++	$(LINK_SHARED_CMD)
++
+ $(OUT)/%.exe: $(OUT)/%.o | $(ALL_DIR)
+ 	$(LINK_CMD)
  
-@@ -141,8 +143,8 @@
+@@ -300,8 +305,8 @@
  
  # --- Library ---
  
@@ -24,16 +34,6 @@
 -THIRD_LIB = $(OUT)/libmupdfthird.a
 +MUPDF_LIB = $(OUT)/libmupdf.so.0
 +THIRD_LIB = $(OUT)/libmupdfthird.so.0
+ THREAD_LIB = $(OUT)/libmuthreads.a
  
- MUPDF_OBJ := $(FITZ_OBJ) $(FONT_OBJ) $(PDF_OBJ) $(XPS_OBJ) $(CBZ_OBJ) $(HTML_OBJ) $(GPRF_OBJ)
- THIRD_OBJ := $(FREETYPE_OBJ) $(HARFBUZZ_OBJ) $(JBIG2DEC_OBJ) $(JPEG_OBJ) $(MUJS_OBJ) $(OPENJPEG_OBJ) $(ZLIB_OBJ)
-@@ -161,6 +163,9 @@
- 	$(RM_CMD)
- 	$(AR_CMD)
- 	$(RANLIB_CMD)
-+
-+$(OUT)/%.so.0 : $(OUT)/%.a
-+	$(LINK_SHARED_CMD)
- 
- $(OUT)/%: $(OUT)/%.o
- 	$(LINK_CMD)
+ MUPDF_OBJ := $(FITZ_OBJ) $(FONT_OBJ) $(PDF_OBJ) $(XPS_OBJ) $(SVG_OBJ) $(CBZ_OBJ) $(HTML_OBJ) $(GPRF_OBJ)
-- 
2.12.2

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