pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc/print/zathura-pdf-mupdf
Module Name: pkgsrc
Committed By: leot
Date: Mon Dec 18 15:07:14 UTC 2017
Modified Files:
pkgsrc/print/zathura-pdf-mupdf: Makefile distinfo
pkgsrc/print/zathura-pdf-mupdf/patches: patch-index.c
Added Files:
pkgsrc/print/zathura-pdf-mupdf/patches: patch-image.c patch-page.c
patch-plugin.h patch-render.c patch-select.c patch-utils.c
Removed Files:
pkgsrc/print/zathura-pdf-mupdf/patches: patch-links.c
Log Message:
zathura-pdf-mupdf: Backport patches from upstream and adapt to MuPDF 1.2.0 API
- Backport all the relevant patches from upstream (NFCI, most of them were
already backported but diverged a bit from upstream).
- Delete patches/patch-links.c, I can no longer reproduce the NULL pointer
dereference with mupdf-1.2.0.
- Backport MuPDF 1.2.0 API update
With these zathura-pdf-mupdf works with mupdf-1.2.0.
Bump PKGREVISION.
To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 pkgsrc/print/zathura-pdf-mupdf/Makefile
cvs rdiff -u -r1.6 -r1.7 pkgsrc/print/zathura-pdf-mupdf/distinfo
cvs rdiff -u -r0 -r1.4 pkgsrc/print/zathura-pdf-mupdf/patches/patch-image.c \
pkgsrc/print/zathura-pdf-mupdf/patches/patch-page.c \
pkgsrc/print/zathura-pdf-mupdf/patches/patch-plugin.h \
pkgsrc/print/zathura-pdf-mupdf/patches/patch-utils.c
cvs rdiff -u -r1.3 -r1.4 pkgsrc/print/zathura-pdf-mupdf/patches/patch-index.c
cvs rdiff -u -r1.3 -r0 pkgsrc/print/zathura-pdf-mupdf/patches/patch-links.c
cvs rdiff -u -r0 -r1.5 pkgsrc/print/zathura-pdf-mupdf/patches/patch-render.c
cvs rdiff -u -r0 -r1.1 pkgsrc/print/zathura-pdf-mupdf/patches/patch-select.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: pkgsrc/print/zathura-pdf-mupdf/Makefile
diff -u pkgsrc/print/zathura-pdf-mupdf/Makefile:1.19 pkgsrc/print/zathura-pdf-mupdf/Makefile:1.20
--- pkgsrc/print/zathura-pdf-mupdf/Makefile:1.19 Thu Nov 23 17:20:10 2017
+++ pkgsrc/print/zathura-pdf-mupdf/Makefile Mon Dec 18 15:07:14 2017
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.19 2017/11/23 17:20:10 wiz Exp $
+# $NetBSD: Makefile,v 1.20 2017/12/18 15:07:14 leot Exp $
#
DISTNAME= zathura-pdf-mupdf-0.3.1
-PKGREVISION= 7
+PKGREVISION= 8
CATEGORIES= print
MASTER_SITES= https://pwmt.org/projects/zathura/plugins/download/
Index: pkgsrc/print/zathura-pdf-mupdf/distinfo
diff -u pkgsrc/print/zathura-pdf-mupdf/distinfo:1.6 pkgsrc/print/zathura-pdf-mupdf/distinfo:1.7
--- pkgsrc/print/zathura-pdf-mupdf/distinfo:1.6 Sat Feb 18 13:38:33 2017
+++ pkgsrc/print/zathura-pdf-mupdf/distinfo Mon Dec 18 15:07:14 2017
@@ -1,9 +1,14 @@
-$NetBSD: distinfo,v 1.6 2017/02/18 13:38:33 leot Exp $
+$NetBSD: distinfo,v 1.7 2017/12/18 15:07:14 leot Exp $
SHA1 (zathura-pdf-mupdf-0.3.1.tar.gz) = ef37a181de96d6fca36db3ac818f790dcf3627ae
RMD160 (zathura-pdf-mupdf-0.3.1.tar.gz) = 7497475ba55d2e7f96d23f378cbefeddd56089e4
SHA512 (zathura-pdf-mupdf-0.3.1.tar.gz) = 87b5b8a750a6911be37a0195b0f4bc3304350f9d29173091b3eeece40350b10cb98b009b2722a69ae1e617b4242292f3eba17fea97d5276e485069180f2bd67d
Size (zathura-pdf-mupdf-0.3.1.tar.gz) = 9755 bytes
SHA1 (patch-document.c) = b4695700ffc3a85667a292af059d0af58b3150f1
-SHA1 (patch-index.c) = fbf31d17bbf979a74160db6d6838a11ce47d37f1
-SHA1 (patch-links.c) = 58581cbe1468ddf9c0e5a58e80c16586977be49b
+SHA1 (patch-image.c) = 65fee62ddeddf5329a9eeb868b39f26c9232f759
+SHA1 (patch-index.c) = 96022a5e5c6152e56cecad8f47c4893419536c83
+SHA1 (patch-page.c) = adbe5766d39befdde4aed0a937ff96312921eb2f
+SHA1 (patch-plugin.h) = 1e93cac827843be7a5caf887c5c3381ad16388f4
+SHA1 (patch-render.c) = 000477afe5286eb6e183cc87864c06f3f73ad8f2
+SHA1 (patch-select.c) = 5b6505ad998e1980a6cfa4dc0484f0707ea9799a
+SHA1 (patch-utils.c) = 870c37dfd7c359ad1e9891a75e9afc71ac3c36c7
Index: pkgsrc/print/zathura-pdf-mupdf/patches/patch-index.c
diff -u pkgsrc/print/zathura-pdf-mupdf/patches/patch-index.c:1.3 pkgsrc/print/zathura-pdf-mupdf/patches/patch-index.c:1.4
--- pkgsrc/print/zathura-pdf-mupdf/patches/patch-index.c:1.3 Sat Feb 18 13:38:33 2017
+++ pkgsrc/print/zathura-pdf-mupdf/patches/patch-index.c Mon Dec 18 15:07:14 2017
@@ -1,49 +1,29 @@
-$NetBSD: patch-index.c,v 1.3 2017/02/18 13:38:33 leot Exp $
+$NetBSD: patch-index.c,v 1.4 2017/12/18 15:07:14 leot Exp $
-Avoid possible NULL-pointer dereference.
+index: handle outline entries with no URI
+
+Some PDFs (such as [1]) cause mupdf to return outline elements with a
+NULL uri element, which causes a NULL pointer dereference to happen in
+fz_is_external_link.
+
+Catch this case, but still create a dummy entry in the outline.
+
+[1] http://www.st.com/resource/en/reference_manual/dm00093941.pdf
+
+Signed-off-by: Florian Larysch <fl%n621.de@localhost>
+
+Backported from upstream, commit 74deda65003386df216c7c0343c86d95c866f5e1.
--- index.c.orig 2017-01-11 21:21:14.000000000 +0000
+++ index.c
-@@ -51,24 +51,26 @@ build_index(fz_context* ctx, fz_document
+@@ -51,7 +51,9 @@ build_index(fz_context* ctx, fz_document
zathura_link_type_t type = ZATHURA_LINK_INVALID;
zathura_rectangle_t rect = { .x1 = 0, .y1 = 0, .x2 = 0, .y2 = 0 };
- if (fz_is_external_link(ctx, outline->uri) == 1) {
-- if (strstr(outline->uri, "file://") == outline->uri) {
-- type = ZATHURA_LINK_GOTO_REMOTE;
-- target.value = outline->uri;
-+ if (outline->uri) {
-+ if (fz_is_external_link(ctx, outline->uri) == 1) {
-+ if (strstr(outline->uri, "file://") == outline->uri) {
-+ type = ZATHURA_LINK_GOTO_REMOTE;
-+ target.value = outline->uri;
-+ } else {
-+ type = ZATHURA_LINK_URI;
-+ target.value = outline->uri;
-+ }
- } else {
-- type = ZATHURA_LINK_URI;
-- target.value = outline->uri;
-+ float x = 0;
-+ float y = 0;
-+
-+ type = ZATHURA_LINK_GOTO_DEST;
-+ target.destination_type = ZATHURA_LINK_DESTINATION_XYZ;
-+ target.page_number = fz_resolve_link(ctx, document, outline->uri, &x, &y);
-+ target.left = x;
-+ target.top = y;
-+ target.scale = 0.0;
- }
-- } else {
-- float x = 0;
-- float y = 0;
--
-- type = ZATHURA_LINK_GOTO_DEST;
-- target.destination_type = ZATHURA_LINK_DESTINATION_XYZ;
-- target.page_number = fz_resolve_link(ctx, document, outline->uri, &x, &y);
-- target.left = x;
-- target.top = y;
-- target.scale = 0.0;
- }
-
- index_element->link = zathura_link_new(type, rect, target);
++ if (outline->uri == NULL) {
++ type = ZATHURA_LINK_NONE;
++ } else if (fz_is_external_link(ctx, outline->uri) == 1) {
+ if (strstr(outline->uri, "file://") == outline->uri) {
+ type = ZATHURA_LINK_GOTO_REMOTE;
+ target.value = outline->uri;
Added files:
Index: pkgsrc/print/zathura-pdf-mupdf/patches/patch-image.c
diff -u /dev/null pkgsrc/print/zathura-pdf-mupdf/patches/patch-image.c:1.4
--- /dev/null Mon Dec 18 15:07:14 2017
+++ pkgsrc/print/zathura-pdf-mupdf/patches/patch-image.c Mon Dec 18 15:07:14 2017
@@ -0,0 +1,35 @@
+$NetBSD: patch-image.c,v 1.4 2017/12/18 15:07:14 leot Exp $
+
+Updated for MuPDF 1.12.0
+
+Backport from upstream, commit a3f703788f77b19bb986e14666fe0c47911adddc.
+
+--- image.c.orig 2017-01-11 21:21:14.000000000 +0000
++++ image.c
+@@ -43,18 +43,16 @@ pdf_page_images_get(zathura_page_t* page
+ /* Extract images */
+ mupdf_page_extract_text(mupdf_document, mupdf_page);
+
+- fz_page_block* block;
+- for (block = mupdf_page->text->blocks; block < mupdf_page->text->blocks + mupdf_page->text->len; block++) {
+- if (block->type == FZ_PAGE_BLOCK_IMAGE) {
+- fz_image_block *image_block = block->u.image;
+-
++ fz_stext_block* block;
++ for (block = mupdf_page->text->first_block; block; block = block->next) {
++ if (block->type == FZ_STEXT_BLOCK_IMAGE) {
+ zathura_image_t* zathura_image = g_malloc(sizeof(zathura_image_t));
+
+- zathura_image->position.x1 = image_block->bbox.x0;
+- zathura_image->position.y1 = image_block->bbox.y0;
+- zathura_image->position.x2 = image_block->bbox.x1;
+- zathura_image->position.y2 = image_block->bbox.y1;
+- zathura_image->data = image_block->image;
++ zathura_image->position.x1 = block->bbox.x0;
++ zathura_image->position.y1 = block->bbox.y0;
++ zathura_image->position.x2 = block->bbox.x1;
++ zathura_image->position.y2 = block->bbox.y1;
++ zathura_image->data = block->u.i.image;
+
+ girara_list_append(list, zathura_image);
+ }
Index: pkgsrc/print/zathura-pdf-mupdf/patches/patch-page.c
diff -u /dev/null pkgsrc/print/zathura-pdf-mupdf/patches/patch-page.c:1.4
--- /dev/null Mon Dec 18 15:07:14 2017
+++ pkgsrc/print/zathura-pdf-mupdf/patches/patch-page.c Mon Dec 18 15:07:14 2017
@@ -0,0 +1,75 @@
+$NetBSD: patch-page.c,v 1.4 2017/12/18 15:07:14 leot Exp $
+
+- Fix double free in pdf_page_init()
+
+ In case of failure in 'pdf_page_init', the mupdf_page is being cleared
+ and freed but the zathura_page still holds a pointer to it, resulting
+ in a double free when 'pdf_page_clear' is later called.
+
+ The execution flow resulting in a double free is the following:
+ zathura_page_new()
+ pdf_page_init()
+ zathura_page_set_data()
+ failure of fz_load_page(),fz_bound_page() or fz_new_stext_sheet()
+ pdf_page_clear()
+ zathura_page_free()
+ pdf_page_clear() // double free
+
+ Make sure 'zathura_page_set_data' is called only if no errors occurred
+ so that page->data never points to freed memory.
+
+ Backported from upstream, commit 83b3f9e77bb6aedfa6b4fffc1088c25ae209fd81.
+
+- Updated for MuPDF 1.12.0
+
+ Backport from upstream, commit a3f703788f77b19bb986e14666fe0c47911adddc.
+
+--- page.c.orig 2017-12-18 10:17:58.832972588 +0000
++++ page.c
+@@ -20,8 +20,6 @@ pdf_page_init(zathura_page_t* page)
+ return ZATHURA_ERROR_OUT_OF_MEMORY;
+ }
+
+- zathura_page_set_data(page, mupdf_page);
+-
+ mupdf_page->ctx = mupdf_document->ctx;
+ if (mupdf_page->ctx == NULL) {
+ goto error_free;
+@@ -36,10 +34,6 @@ pdf_page_init(zathura_page_t* page)
+
+ fz_bound_page(mupdf_document->ctx, (fz_page*) mupdf_page->page, &mupdf_page->bbox);
+
+- /* get page dimensions */
+- zathura_page_set_width(page, mupdf_page->bbox.x1 - mupdf_page->bbox.x0);
+- zathura_page_set_height(page, mupdf_page->bbox.y1 - mupdf_page->bbox.y0);
+-
+ /* setup text */
+ mupdf_page->extracted_text = false;
+
+@@ -50,10 +44,11 @@ pdf_page_init(zathura_page_t* page)
+ goto error_free;
+ }
+
+- mupdf_page->sheet = fz_new_stext_sheet(mupdf_page->ctx);
+- if (mupdf_page->sheet == NULL) {
+- goto error_free;
+- }
++ zathura_page_set_data(page, mupdf_page);
++
++ /* get page dimensions */
++ zathura_page_set_width(page, mupdf_page->bbox.x1 - mupdf_page->bbox.x0);
++ zathura_page_set_height(page, mupdf_page->bbox.y1 - mupdf_page->bbox.y0);
+
+ return ZATHURA_ERROR_OK;
+
+@@ -79,10 +74,6 @@ pdf_page_clear(zathura_page_t* page, mup
+ fz_drop_stext_page(mupdf_page->ctx, mupdf_page->text);
+ }
+
+- if (mupdf_page->sheet != NULL) {
+- fz_drop_stext_sheet(mupdf_page->ctx, mupdf_page->sheet);
+- }
+-
+ if (mupdf_page->page != NULL) {
+ fz_drop_page(mupdf_document->ctx, mupdf_page->page);
+ }
Index: pkgsrc/print/zathura-pdf-mupdf/patches/patch-plugin.h
diff -u /dev/null pkgsrc/print/zathura-pdf-mupdf/patches/patch-plugin.h:1.4
--- /dev/null Mon Dec 18 15:07:14 2017
+++ pkgsrc/print/zathura-pdf-mupdf/patches/patch-plugin.h Mon Dec 18 15:07:14 2017
@@ -0,0 +1,25 @@
+$NetBSD: patch-plugin.h,v 1.4 2017/12/18 15:07:14 leot Exp $
+
+Updated for MuPDF 1.12.0
+
+Backport from upstream, commit a3f703788f77b19bb986e14666fe0c47911adddc.
+
+--- plugin.h.orig 2017-01-11 21:21:14.000000000 +0000
++++ plugin.h
+@@ -3,6 +3,8 @@
+ #ifndef PDF_H
+ #define PDF_H
+
++#include <stdlib.h>
++#include <string.h>
+ #include <stdbool.h>
+ #include <zathura/plugin-api.h>
+ #include <mupdf/fitz.h>
+@@ -21,7 +23,6 @@ typedef struct mupdf_page_s
+ {
+ fz_page* page; /**< Reference to the mupdf page */
+ fz_context* ctx; /**< Context */
+- fz_stext_sheet* sheet; /**< Text sheet */
+ fz_stext_page* text; /**< Page text */
+ fz_rect bbox; /**< Bbox */
+ bool extracted_text; /**< If text has already been extracted */
Index: pkgsrc/print/zathura-pdf-mupdf/patches/patch-utils.c
diff -u /dev/null pkgsrc/print/zathura-pdf-mupdf/patches/patch-utils.c:1.4
--- /dev/null Mon Dec 18 15:07:14 2017
+++ pkgsrc/print/zathura-pdf-mupdf/patches/patch-utils.c Mon Dec 18 15:07:14 2017
@@ -0,0 +1,30 @@
+$NetBSD: patch-utils.c,v 1.4 2017/12/18 15:07:14 leot Exp $
+
+Updated for MuPDF 1.12.0
+
+Backport from upstream, commit a3f703788f77b19bb986e14666fe0c47911adddc.
+
+--- utils.c.orig 2017-01-11 21:21:14.000000000 +0000
++++ utils.c
+@@ -7,17 +7,17 @@
+ void
+ mupdf_page_extract_text(mupdf_document_t* mupdf_document, mupdf_page_t* mupdf_page) {
+ if (mupdf_document == NULL || mupdf_document->ctx == NULL || mupdf_page == NULL ||
+- mupdf_page->sheet == NULL || mupdf_page->text == NULL) {
++ mupdf_page->text == NULL) {
+ return;
+ }
+
+ fz_device* text_device = NULL;
+
+ fz_try (mupdf_page->ctx) {
+- text_device = fz_new_stext_device(mupdf_page->ctx, mupdf_page->sheet, mupdf_page->text, NULL);
++ text_device = fz_new_stext_device(mupdf_page->ctx, mupdf_page->text, NULL);
+
+- /* Disable FZ_IGNORE_IMAGE to collect image blocks */
+- fz_disable_device_hints(mupdf_page->ctx, text_device, FZ_IGNORE_IMAGE);
++ /* Disable FZ_DONT_INTERPOLATE_IMAGES to collect image blocks */
++ fz_disable_device_hints(mupdf_page->ctx, text_device, FZ_DONT_INTERPOLATE_IMAGES);
+
+ fz_matrix ctm;
+ fz_scale(&ctm, 1.0, 1.0);
Index: pkgsrc/print/zathura-pdf-mupdf/patches/patch-render.c
diff -u /dev/null pkgsrc/print/zathura-pdf-mupdf/patches/patch-render.c:1.5
--- /dev/null Mon Dec 18 15:07:14 2017
+++ pkgsrc/print/zathura-pdf-mupdf/patches/patch-render.c Mon Dec 18 15:07:14 2017
@@ -0,0 +1,48 @@
+$NetBSD: patch-render.c,v 1.5 2017/12/18 15:07:14 leot Exp $
+
+- Close device.
+
+ Every fz_drop_device() need a corresponding fz_close_device().
+
+ This fixes the:
+
+ warning: dropping unclosed device
+ warning: ... repeated <n> times ..
+
+ warnings.
+
+ Backport from upstream, commit 622b35440d708a187add31adab8bca747c11d2a8.
+
+- Updated for MuPDF 1.12.0
+
+ Backport from upstream, commit a3f703788f77b19bb986e14666fe0c47911adddc.
+
+--- render.c.orig 2017-01-11 21:21:14.000000000 +0000
++++ render.c
+@@ -31,21 +31,25 @@ pdf_page_render_to_buffer(mupdf_document
+ return ZATHURA_ERROR_UNKNOWN;
+ }
+
++ fz_close_device(mupdf_page->ctx, device);
+ fz_drop_device(mupdf_page->ctx, device);
+
+ fz_irect irect = { .x1 = page_width, .y1 = page_height };
+ fz_rect rect = { .x1 = page_width, .y1 = page_height };
+
+ fz_colorspace* colorspace = fz_device_bgr(mupdf_document->ctx);
+- fz_pixmap* pixmap = fz_new_pixmap_with_bbox_and_data(mupdf_page->ctx, colorspace, &irect, 1, image);
++ fz_separations* seps= fz_page_separations(mupdf_page->ctx, mupdf_page->page);
++ fz_pixmap* pixmap = fz_new_pixmap_with_bbox_and_data(mupdf_page->ctx, colorspace, &irect, seps, 1, image);
+ fz_clear_pixmap_with_value(mupdf_page->ctx, pixmap, 0xFF);
+
+ device = fz_new_draw_device(mupdf_page->ctx, NULL, pixmap);
+ fz_run_display_list(mupdf_page->ctx, display_list, device, &fz_identity, &rect, NULL);
++ fz_close_device(mupdf_page->ctx, device);
+ fz_drop_device(mupdf_page->ctx, device);
+
+ fz_drop_pixmap(mupdf_page->ctx, pixmap);
+ fz_drop_display_list(mupdf_page->ctx, display_list);
++ fz_drop_separations(mupdf_page->ctx, seps);
+
+ return ZATHURA_ERROR_OK;
+ }
Index: pkgsrc/print/zathura-pdf-mupdf/patches/patch-select.c
diff -u /dev/null pkgsrc/print/zathura-pdf-mupdf/patches/patch-select.c:1.1
--- /dev/null Mon Dec 18 15:07:14 2017
+++ pkgsrc/print/zathura-pdf-mupdf/patches/patch-select.c Mon Dec 18 15:07:14 2017
@@ -0,0 +1,25 @@
+$NetBSD: patch-select.c,v 1.1 2017/12/18 15:07:14 leot Exp $
+
+Updated for MuPDF 1.12.0
+
+Backport from upstream, commit a3f703788f77b19bb986e14666fe0c47911adddc.
+
+--- select.c.orig 2017-01-11 21:21:14.000000000 +0000
++++ select.c
+@@ -24,9 +24,14 @@ pdf_page_get_text(zathura_page_t* page,
+ mupdf_page_extract_text(mupdf_document, mupdf_page);
+ }
+
+- fz_rect rect = { rectangle.x1, rectangle.y1, rectangle.x2, rectangle.y2 };
++ fz_point a = { rectangle.x1, rectangle.y1 };
++ fz_point b = { rectangle.x2, rectangle.y2 };
+
+- return fz_copy_selection(mupdf_page->ctx, mupdf_page->text, rect);
++#ifdef _WIN32
++ return fz_copy_selection(mupdf_page->ctx, mupdf_page->text, a, b, 1);
++#else
++ return fz_copy_selection(mupdf_page->ctx, mupdf_page->text, a, b, 0);
++#endif
+
+ error_ret:
+
Home |
Main Index |
Thread Index |
Old Index