evince/0001-comics-Fix-decoding-some-files-in-RAR-archives.patch
Bastien Nocera 57fcccecf1 + evince-3.24.0-3
Use libarchive to handle compressed comics documents
Resolves: #1468488
2017-07-12 13:37:21 +02:00

46 lines
1.6 KiB
Diff

From 499cd2025bc21ca725915f0e0b618bf8df2a0596 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
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