Gentoo Archives: gentoo-commits

From: Michael Weber <xmw@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-text/mupdf/, app-text/mupdf/files/
Date: Mon, 06 Mar 2017 22:12:59
Message-Id: 1488838368.8231bc27f9ef5caa6f21b3601047797c432adb7c.xmw@gentoo
1 commit: 8231bc27f9ef5caa6f21b3601047797c432adb7c
2 Author: Michael Weber <xmw <AT> gentoo <DOT> org>
3 AuthorDate: Mon Mar 6 22:12:21 2017 +0000
4 Commit: Michael Weber <xmw <AT> gentoo <DOT> org>
5 CommitDate: Mon Mar 6 22:12:48 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8231bc27
7
8 app-text/mupdf: Revbump with patch for CVE-2017-5991.
9
10 Package-Manager: Portage-2.3.4, Repoman-2.3.2
11
12 .../mupdf/files/mupdf-1.10a-null-pointer-2.patch | 88 ++++++++++++
13 app-text/mupdf/mupdf-1.10a-r2.ebuild | 148 +++++++++++++++++++++
14 2 files changed, 236 insertions(+)
15
16 diff --git a/app-text/mupdf/files/mupdf-1.10a-null-pointer-2.patch b/app-text/mupdf/files/mupdf-1.10a-null-pointer-2.patch
17 new file mode 100644
18 index 00000000000..a4fefb79ca6
19 --- /dev/null
20 +++ b/app-text/mupdf/files/mupdf-1.10a-null-pointer-2.patch
21 @@ -0,0 +1,88 @@
22 +From: Robin Watts <robin.watts@×××××××.com>
23 +Date: Thu, 9 Feb 2017 15:49:15 +0000 (+0000)
24 +Subject: Bug 697500: Fix NULL ptr access.
25 +X-Git-Url: http://git.ghostscript.com/?p=mupdf.git;a=commitdiff_plain;h=1912de5f08e90af1d9d0a9791f58ba3afdb9d465;hp=2c4e5867ee699b1081527bc6c6ea0e99a35a5c27
26 +
27 +Bug 697500: Fix NULL ptr access.
28 +
29 +Cope better with errors during rendering - avoid letting the
30 +gstate stack get out of sync.
31 +
32 +This avoids us ever getting into the situation of popping
33 +a clip when we should be popping a mask or a group. This was
34 +causing an unexpected case in the painting.
35 +---
36 +
37 +diff --git a/source/pdf/pdf-op-run.c b/source/pdf/pdf-op-run.c
38 +index a3ea895..f1eac8d 100644
39 +--- a/source/pdf/pdf-op-run.c
40 ++++ b/source/pdf/pdf-op-run.c
41 +@@ -1213,6 +1213,7 @@ pdf_run_xobject(fz_context *ctx, pdf_run_processor *proc, pdf_xobject *xobj, pdf
42 + pdf_run_processor *pr = (pdf_run_processor *)proc;
43 + pdf_gstate *gstate = NULL;
44 + int oldtop = 0;
45 ++ int oldbot = -1;
46 + fz_matrix local_transform = *transform;
47 + softmask_save softmask = { NULL };
48 + int gparent_save;
49 +@@ -1232,16 +1233,17 @@ pdf_run_xobject(fz_context *ctx, pdf_run_processor *proc, pdf_xobject *xobj, pdf
50 + fz_var(cleanup_state);
51 + fz_var(gstate);
52 + fz_var(oldtop);
53 ++ fz_var(oldbot);
54 +
55 + gparent_save = pr->gparent;
56 + pr->gparent = pr->gtop;
57 ++ oldtop = pr->gtop;
58 +
59 + fz_try(ctx)
60 + {
61 + pdf_gsave(ctx, pr);
62 +
63 + gstate = pr->gstate + pr->gtop;
64 +- oldtop = pr->gtop;
65 +
66 + pdf_xobject_bbox(ctx, xobj, &xobj_bbox);
67 + pdf_xobject_matrix(ctx, xobj, &xobj_matrix);
68 +@@ -1302,12 +1304,25 @@ pdf_run_xobject(fz_context *ctx, pdf_run_processor *proc, pdf_xobject *xobj, pdf
69 +
70 + doc = pdf_get_bound_document(ctx, xobj->obj);
71 +
72 ++ oldbot = pr->gbot;
73 ++ pr->gbot = pr->gtop;
74 ++
75 + pdf_process_contents(ctx, (pdf_processor*)pr, doc, resources, xobj->obj, NULL);
76 + }
77 + fz_always(ctx)
78 + {
79 ++ /* Undo any gstate mismatches due to the pdf_process_contents call */
80 ++ if (oldbot != -1)
81 ++ {
82 ++ while (pr->gtop > pr->gbot)
83 ++ {
84 ++ pdf_grestore(ctx, pr);
85 ++ }
86 ++ pr->gbot = oldbot;
87 ++ }
88 ++
89 + if (cleanup_state >= 3)
90 +- pdf_grestore(ctx, pr); /* Remove the clippath */
91 ++ pdf_grestore(ctx, pr); /* Remove the state we pushed for the clippath */
92 +
93 + /* wrap up transparency stacks */
94 + if (transparency)
95 +@@ -1341,13 +1356,8 @@ pdf_run_xobject(fz_context *ctx, pdf_run_processor *proc, pdf_xobject *xobj, pdf
96 + pr->gstate[pr->gparent].ctm = gparent_save_ctm;
97 + pr->gparent = gparent_save;
98 +
99 +- if (gstate)
100 +- {
101 +- while (oldtop < pr->gtop)
102 +- pdf_grestore(ctx, pr);
103 +-
104 ++ while (oldtop < pr->gtop)
105 + pdf_grestore(ctx, pr);
106 +- }
107 +
108 + pdf_unmark_obj(ctx, xobj->obj);
109 + }
110
111 diff --git a/app-text/mupdf/mupdf-1.10a-r2.ebuild b/app-text/mupdf/mupdf-1.10a-r2.ebuild
112 new file mode 100644
113 index 00000000000..6fb8e5ac911
114 --- /dev/null
115 +++ b/app-text/mupdf/mupdf-1.10a-r2.ebuild
116 @@ -0,0 +1,148 @@
117 +# Copyright 1999-2017 Gentoo Foundation
118 +# Distributed under the terms of the GNU General Public License v2
119 +
120 +EAPI=6
121 +
122 +inherit flag-o-matic toolchain-funcs
123 +
124 +DESCRIPTION="a lightweight PDF viewer and toolkit written in portable C"
125 +HOMEPAGE="http://mupdf.com/"
126 +SRC_URI="http://mupdf.com/downloads/${P}-source.tar.gz"
127 +
128 +LICENSE="AGPL-3"
129 +SLOT="0/${PV}"
130 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86 ~amd64-linux ~ppc-macos ~x64-macos ~x86-macos"
131 +IUSE="X +curl javascript libressl opengl +openssl static static-libs vanilla"
132 +
133 +LIB_DEPEND="
134 + !libressl? ( dev-libs/openssl:0[static-libs?] )
135 + libressl? ( dev-libs/libressl[static-libs?] )
136 + javascript? ( >=dev-lang/mujs-0_p20160504 )
137 + media-libs/freetype:2[static-libs?]
138 + media-libs/harfbuzz[static-libs?]
139 + media-libs/jbig2dec[static-libs?]
140 + media-libs/libpng:0[static-libs?]
141 + >=media-libs/openjpeg-2.1:2[static-libs?]
142 + net-misc/curl[static-libs?]
143 + virtual/jpeg[static-libs?]
144 + X? ( x11-libs/libX11[static-libs?]
145 + x11-libs/libXext[static-libs?] )
146 + opengl? ( >=media-libs/glfw-3 )"
147 +RDEPEND="${LIB_DEPEND}"
148 +DEPEND="${RDEPEND}
149 + virtual/pkgconfig
150 + static-libs? ( ${LIB_DEPEND} )
151 + static? ( ${LIB_DEPEND//?}
152 + app-arch/bzip2[static-libs]
153 + x11-libs/libXau[static-libs]
154 + x11-libs/libXdmcp[static-libs]
155 + x11-libs/libxcb[static-libs] )"
156 +
157 +REQUIRED_USE="opengl? ( X !static !static-libs )"
158 +
159 +S=${WORKDIR}/${P}-source
160 +
161 +PATCHES=(
162 + "${FILESDIR}"/${PN}-1.9a-CFLAGS.patch
163 + "${FILESDIR}"/${PN}-1.9a-debug-build.patch
164 + "${FILESDIR}"/${PN}-1.10a-add-desktop-pc-xpm-files.patch
165 + "${FILESDIR}"/${PN}-1.10a-Makerules-openssl-curl.patch
166 + "${FILESDIR}"/${PN}-1.8-system-glfw.patch
167 + "${FILESDIR}"/${PN}-1.10a-heap-overflow.patch
168 + "${FILESDIR}"/${PN}-1.10a-null-pointer.patch
169 + "${FILESDIR}"/${PN}-1.10a-null-pointer-2.patch
170 +)
171 +
172 +src_prepare() {
173 + default
174 + use hppa && append-cflags -ffunction-sections
175 +
176 + rm -rf thirdparty || die
177 +
178 + if has_version ">=media-libs/openjpeg-2.1:2" ; then
179 + # Remove a switch, which prevents using shared libraries for openjpeg2.
180 + # See http://www.linuxfromscratch.org/blfs/view/cvs/pst/mupdf.html
181 + sed '/OPJ_STATIC$/d' -i source/fitz/load-jpx.c
182 + fi
183 +
184 + use javascript || \
185 + sed -e '/* #define FZ_ENABLE_JS/ a\#define FZ_ENABLE_JS 0' \
186 + -i include/mupdf/fitz/config.h
187 +
188 + sed -e "/^libdir=/s:/lib:/$(get_libdir):" \
189 + -e "/^prefix=/s:=.*:=${EROOT}/usr:" \
190 + -i platform/debian/${PN}.pc || die
191 +
192 + use vanilla || eapply \
193 + "${FILESDIR}"/${PN}-1.3-zoom-2.patch
194 +
195 + sed -e "1iOS = Linux" \
196 + -e "1iCC = $(tc-getCC)" \
197 + -e "1iLD = $(tc-getCC)" \
198 + -e "1iAR = $(tc-getAR)" \
199 + -e "1iverbose = yes" \
200 + -e "1ibuild = debug" \
201 + -e "1iprefix = ${ED}usr" \
202 + -e "1ilibdir = ${ED}usr/$(get_libdir)" \
203 + -e "1idocdir = ${ED}usr/share/doc/${PF}" \
204 + -e "1iHAVE_X11 = $(usex X)" \
205 + -e "1iWANT_OPENSSL = $(usex openssl)" \
206 + -e "1iWANT_CURL = $(usex curl)" \
207 + -e "1iHAVE_MUJS = $(usex javascript)" \
208 + -e "1iMUJS_LIBS = $(usex javascript -lmujs '')" \
209 + -e "1iMUJS_CFLAGS =" \
210 + -e "1iHAVE_GLFW = $(usex opengl yes no)" \
211 + -i Makerules || die
212 +
213 + if use static-libs || use static ; then
214 + cp -a "${S}" "${S}"-static || die
215 + #add missing Libs.private for xcb and freetype
216 + sed -e 's:\(pkg-config --libs\):\1 --static:' \
217 + -e '/^SYS_X11_LIBS = /s:\(.*\):\1 -lpthread:' \
218 + -e '/^SYS_FREETYPE_LIBS = /s:\(.*\):\1 -lbz2:' \
219 + -i "${S}"-static/Makerules || die
220 + fi
221 +
222 + my_soname=libmupdf.so.${PV}
223 + my_soname_js_none=libmupdf-js-none.so.${PV}
224 + sed -e "\$a\$(MUPDF_LIB): \$(MUPDF_JS_NONE_LIB)" \
225 + -e "\$a\\\t\$(QUIET_LINK) \$(CC) \$(LDFLAGS) --shared -Wl,-soname -Wl,${my_soname} -Wl,--no-undefined -o \$@ \$^ \$(MUPDF_JS_NONE_LIB) \$(LIBS)" \
226 + -e "/^MUPDF_LIB =/s:=.*:= \$(OUT)/${my_soname}:" \
227 + -e "\$a\$(MUPDF_JS_NONE_LIB):" \
228 + -e "\$a\\\t\$(QUIET_LINK) \$(CC) \$(LDFLAGS) --shared -Wl,-soname -Wl,${my_soname_js_none} -Wl,--no-undefined -o \$@ \$^ \$(LIBS)" \
229 + -e "/install/s: COPYING : :" \
230 + -i Makefile || die
231 +}
232 +
233 +src_compile() {
234 + emake XCFLAGS="-fpic"
235 + use static-libs && \
236 + emake -C "${S}"-static build/debug/lib${PN}{,-js-none}.a
237 + use static && \
238 + emake -C "${S}"-static XLIBS="-static"
239 +}
240 +
241 +src_install() {
242 + if use X ; then
243 + domenu platform/debian/${PN}.desktop
244 + doicon platform/debian/${PN}.xpm
245 + else
246 + rm docs/man/${PN}.1
247 + fi
248 +
249 + emake install
250 + dosym ${my_soname} /usr/$(get_libdir)/lib${PN}.so
251 +
252 + use static-libs && \
253 + dolib.a "${S}"-static/build/debug/lib${PN}{,-js-none}.a
254 + if use static ; then
255 + dobin "${S}"-static/build/debug/mu{tool,draw}
256 + use X && dobin "${S}"-static/build/debug/${PN}-x11
257 + fi
258 + use X && dosym ${PN}-x11 /usr/bin/${PN}
259 +
260 + insinto /usr/$(get_libdir)/pkgconfig
261 + doins platform/debian/${PN}.pc
262 +
263 + dodoc README docs/*.{txt,c}
264 +}