From e79b35cbba5ca856cc8589face5a6c4b17297ec8 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Thu, 13 Jul 2017 14:26:12 +0200 Subject: [PATCH] Missed an intermediary patch --- ...-decoding-some-files-in-RAR-archives.patch | 45 ------- evince-libarchive-gnome-3-24.patch | 117 +++++++++++++++--- evince.spec | 1 - 3 files changed, 100 insertions(+), 63 deletions(-) delete mode 100644 0001-comics-Fix-decoding-some-files-in-RAR-archives.patch diff --git a/0001-comics-Fix-decoding-some-files-in-RAR-archives.patch b/0001-comics-Fix-decoding-some-files-in-RAR-archives.patch deleted file mode 100644 index 145bc3e..0000000 --- a/0001-comics-Fix-decoding-some-files-in-RAR-archives.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 499cd2025bc21ca725915f0e0b618bf8df2a0596 Mon Sep 17 00:00:00 2001 -From: Bastien Nocera -Date: Wed, 12 Jul 2017 12:53:19 +0200 -Subject: [PATCH] comics: Fix decoding some files in RAR archives - -The unarr RAR decoder doesn't like it when we request more data than is -available: -! rar.c:169: Requesting too much data (3563 < 10240) - -Clamp the size of the read request to the data left to read. - -https://bugzilla.gnome.org/show_bug.cgi?id=784842 ---- - backend/comics/comics-document.c | 9 +++++++-- - 1 file changed, 7 insertions(+), 2 deletions(-) - -diff --git a/backend/comics/comics-document.c b/backend/comics/comics-document.c -index ee060091..a913641d 100644 ---- a/backend/comics/comics-document.c -+++ b/backend/comics/comics-document.c -@@ -318,14 +318,19 @@ comics_document_get_page_size (EvDocument *document, - if (g_strcmp0 (name, page_path) == 0) { - char buf[BLOCK_SIZE]; - gssize read; -+ gint64 left; - -- read = ev_archive_read_data (comics_document->archive, buf, sizeof(buf), &error); -+ left = ev_archive_get_entry_size (comics_document->archive); -+ read = ev_archive_read_data (comics_document->archive, buf, -+ MIN(BLOCK_SIZE, left), &error); - while (read > 0 && !info.got_info) { - if (!gdk_pixbuf_loader_write (loader, (guchar *) buf, read, &error)) { - read = -1; - break; - } -- read = ev_archive_read_data (comics_document->archive, buf, BLOCK_SIZE, &error); -+ left -= read; -+ read = ev_archive_read_data (comics_document->archive, buf, -+ MIN(BLOCK_SIZE, left), &error); - } - if (read < 0) { - g_warning ("Fatal error reading '%s' in archive: %s", name, error->message); --- -2.13.0 - diff --git a/evince-libarchive-gnome-3-24.patch b/evince-libarchive-gnome-3-24.patch index aa7dbbd..3dc9f34 100644 --- a/evince-libarchive-gnome-3-24.patch +++ b/evince-libarchive-gnome-3-24.patch @@ -1,7 +1,7 @@ -From d1b02669443d3b18a224f3d63710c17a0553bdad Mon Sep 17 00:00:00 2001 +From 275560fc30cf3fc3bf630941dd70b04e771c05f5 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Thu, 29 Jan 2015 16:54:21 +0100 -Subject: [PATCH 1/8] comics: Port to using libarchive for unarchiving +Subject: [PATCH 01/10] comics: Port to using libarchive for unarchiving v8: - Fix double-free in error path when decompressing images @@ -1476,10 +1476,10 @@ index 9e9f8316..a5ae8ccd 100644 2.13.0 -From ef5fa12af73a698e03356f338d801b39a1e7281d Mon Sep 17 00:00:00 2001 +From dda98ee300df709c10c7025ad527a7969796c527 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Sat, 25 Mar 2017 11:33:42 +0100 -Subject: [PATCH 2/8] comics: cosmetic changes +Subject: [PATCH 02/10] comics: cosmetic changes --- backend/comics/comics-document.c | 109 ++++++++++++++++++--------------------- @@ -1909,10 +1909,10 @@ index 38d47d79..3e206939 100644 2.13.0 -From b406f5a0286413a2debb5f978951b1c3f6098a5c Mon Sep 17 00:00:00 2001 +From 1497b8f6bd30a7a560d190399dd150aa15a96301 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Wed, 15 Mar 2017 18:10:17 +0100 -Subject: [PATCH 3/8] comics: Add unarr copy/paste +Subject: [PATCH 03/10] comics: Add unarr copy/paste To allow us to decompress CBR comics compressed with recent versions of RAR, from https://github.com/sumatrapdfreader/sumatrapdf/tree/master/ext/unarr @@ -10920,10 +10920,10 @@ index 00000000..5ef7447c 2.13.0 -From 8606199554b482b792ab009c49dad59f6c61547c Mon Sep 17 00:00:00 2001 +From 9ec025b3d17edebc0bbdd466f789c4740bbb1268 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Wed, 15 Mar 2017 18:28:42 +0100 -Subject: [PATCH 4/8] comics: Fix "no previous prototype for..." errors +Subject: [PATCH 04/10] comics: Fix "no previous prototype for..." errors Functions that aren't used outside the C file should be marked as static. @@ -10964,11 +10964,11 @@ index 74c2ea61..3df490d4 100644 2.13.0 -From e8d80996295e2463943918bdadb628f368df0988 Mon Sep 17 00:00:00 2001 +From 5ab715e60cad52ed1a71e3269e6120851bd8d221 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Wed, 15 Mar 2017 18:28:34 +0100 -Subject: [PATCH 5/8] =?UTF-8?q?comics:=20Fix=20"function=20declaration=20i?= - =?UTF-8?q?sn=E2=80=99t=20a=20prototype"=20errors?= +Subject: [PATCH 05/10] =?UTF-8?q?comics:=20Fix=20"function=20declaration?= + =?UTF-8?q?=20isn=E2=80=99t=20a=20prototype"=20errors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @@ -11015,10 +11015,10 @@ index 4fb0b47f..51567a9a 100644 2.13.0 -From 16711b99c713b5ff2ff1f3d2e91a4927dfc34314 Mon Sep 17 00:00:00 2001 +From 283c897b5e4bb935014ab6ebd3d424bdead49c8c Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Wed, 15 Mar 2017 19:00:50 +0100 -Subject: [PATCH 6/8] comics: Add unarr support +Subject: [PATCH 06/10] comics: Add unarr support We support all the type of RAR archives now! @@ -11192,10 +11192,10 @@ index 333db470..4c423ef2 100644 2.13.0 -From fb4333feb64ba3facee8907195a56470d6b3ea36 Mon Sep 17 00:00:00 2001 +From adcd3dff47d20e657c5b825ed5192a3e8cdda444 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Sat, 25 Mar 2017 12:34:38 +0100 -Subject: [PATCH 7/8] comics: Add ev_archive_reset() +Subject: [PATCH 07/10] comics: Add ev_archive_reset() And use it instead of destroying and re-creating the EvArchive. This way we don't need to keep the archive type in the document either. @@ -11352,10 +11352,10 @@ index 3e206939..cb526698 100644 2.13.0 -From db4f4ec44bc32682c9f648f697e83c7e13c5a9eb Mon Sep 17 00:00:00 2001 +From 5a81953bb79d3398bf143e8499cde3c6b527ba05 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Sat, 25 Mar 2017 12:38:07 +0100 -Subject: [PATCH 8/8] comic: correctly handle NONE archive type in several +Subject: [PATCH 08/10] comic: correctly handle NONE archive type in several methods --- @@ -11394,3 +11394,86 @@ index e8a93682..7556a49c 100644 -- 2.13.0 + +From f919d85005d0573c92eb2df231855704c90a8602 Mon Sep 17 00:00:00 2001 +From: Bastien Nocera +Date: Tue, 11 Jul 2017 13:41:09 +0200 +Subject: [PATCH 09/10] comics: Don't throw errors in a loop if image is not + readable + +If the file inside the comics archive isn't a readable image file, then +the loader would get closed but we'd keep trying to feed it data, +leading to tons of warnings. + +Exit early with the gdk-pixbuf loader error instead. + +https://bugzilla.gnome.org/show_bug.cgi?id=784790 +--- + backend/comics/comics-document.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/backend/comics/comics-document.c b/backend/comics/comics-document.c +index 5e07df4d..ee060091 100644 +--- a/backend/comics/comics-document.c ++++ b/backend/comics/comics-document.c +@@ -321,7 +321,10 @@ comics_document_get_page_size (EvDocument *document, + + read = ev_archive_read_data (comics_document->archive, buf, sizeof(buf), &error); + while (read > 0 && !info.got_info) { +- gdk_pixbuf_loader_write (loader, (guchar *) buf, read, NULL); ++ if (!gdk_pixbuf_loader_write (loader, (guchar *) buf, read, &error)) { ++ read = -1; ++ break; ++ } + read = ev_archive_read_data (comics_document->archive, buf, BLOCK_SIZE, &error); + } + if (read < 0) { +-- +2.13.0 + + +From 42dbbf4f8236c83c9c7101b34b97ea3face872d4 Mon Sep 17 00:00:00 2001 +From: Bastien Nocera +Date: Wed, 12 Jul 2017 12:53:19 +0200 +Subject: [PATCH 10/10] comics: Fix decoding some files in RAR archives + +The unarr RAR decoder doesn't like it when we request more data than is +available: +! rar.c:169: Requesting too much data (3563 < 10240) + +Clamp the size of the read request to the data left to read. + +https://bugzilla.gnome.org/show_bug.cgi?id=784842 +--- + backend/comics/comics-document.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/backend/comics/comics-document.c b/backend/comics/comics-document.c +index ee060091..a913641d 100644 +--- a/backend/comics/comics-document.c ++++ b/backend/comics/comics-document.c +@@ -318,14 +318,19 @@ comics_document_get_page_size (EvDocument *document, + if (g_strcmp0 (name, page_path) == 0) { + char buf[BLOCK_SIZE]; + gssize read; ++ gint64 left; + +- read = ev_archive_read_data (comics_document->archive, buf, sizeof(buf), &error); ++ left = ev_archive_get_entry_size (comics_document->archive); ++ read = ev_archive_read_data (comics_document->archive, buf, ++ MIN(BLOCK_SIZE, left), &error); + while (read > 0 && !info.got_info) { + if (!gdk_pixbuf_loader_write (loader, (guchar *) buf, read, &error)) { + read = -1; + break; + } +- read = ev_archive_read_data (comics_document->archive, buf, BLOCK_SIZE, &error); ++ left -= read; ++ read = ev_archive_read_data (comics_document->archive, buf, ++ MIN(BLOCK_SIZE, left), &error); + } + if (read < 0) { + g_warning ("Fatal error reading '%s' in archive: %s", name, error->message); +-- +2.13.0 + diff --git a/evince.spec b/evince.spec index 3e7272f..258476e 100644 --- a/evince.spec +++ b/evince.spec @@ -21,7 +21,6 @@ Patch4: 0001-Resolves-rhbz-1358249-page-up-down.patch Patch5: 0001-Revert-Bump-poppler-requirements-to-0.33.0.patch # https://bugzilla.redhat.com/show_bug.cgi?id=1468488 Patch6: evince-libarchive-gnome-3-24.patch -Patch7: 0001-comics-Fix-decoding-some-files-in-RAR-archives.patch BuildRequires: pkgconfig(adwaita-icon-theme) BuildRequires: pkgconfig(gio-unix-2.0) >= %{glib2_version}