1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-05 06:27:37 +00:00

textproc/ebook-tools: fix bug wit invalid epub files

https://bugs.kde.org/show_bug.cgi?id=406116
This commit is contained in:
Tobias C. Berner 2019-05-04 11:53:35 +00:00
parent 3e46ced2b6
commit ee0f9fb135
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=500806
2 changed files with 60 additions and 1 deletions

View File

@ -3,7 +3,7 @@
PORTNAME= ebook-tools
PORTVERSION= 0.2.2
PORTREVISION= 4
PORTREVISION= 5
CATEGORIES= textproc kde
MASTER_SITES= SF

View File

@ -0,0 +1,59 @@
Fix bug in libepub which may lead to crashes in baloo.
[1] https://bugsfiles.kde.org/attachment.cgi?id=119785
[2] https://sourceforge.net/projects/ebook-tools/
[3] https://bugs.kde.org/show_bug.cgi?id=406116
[4] https://sourceforge.net/p/ebook-tools/bugs/8/
From 93ebf942a90f9c95797838f9adab94bc0378671c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
Date: Tue, 30 Apr 2019 16:36:09 +0200
Subject: [PATCH] Avoid crash on toc.ncx navPoint without navLabel
Althoug at least one navLabel is required per navPoint, there is no
guarantee it actually exists.
Avoid crashes due to invalid accesses of a null label in case the toc is
broken, and spew a warning.
Fixes #8 epub_tit_next crashes on navPoint without navLabel.
---
ebook-tools/src/libepub/epub.c | 5 +++--
ebook-tools/src/libepub/opf.c | 4 ++++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git ebook-tools/src/libepub/epub.c ebook-tools/src/libepub/epub.c
index d085503..a259d9d 100644
--- src/libepub/epub.c
+++ src/libepub/epub.c
@@ -469,8 +469,9 @@ int epub_tit_next(struct titerator *tit) {
case TITERATOR_NAVMAP:
case TITERATOR_PAGES:
ti = GetNodeData(curr);
- tit->cache.label =
- (char *)_opf_label_get_by_doc_lang(tit->epub->opf, ti->label);
+ if (ti->label)
+ tit->cache.label =
+ (char *)_opf_label_get_by_doc_lang(tit->epub->opf, ti->label);
if (! tit->cache.label)
tit->cache.label = (char *)ti->id;
diff --git ebook-tools/src/libepub/opf.c ebook-tools/src/libepub/opf.c
index 6851db2..09bce9e 100644
--- src/libepub/opf.c
+++ src/libepub/opf.c
@@ -398,6 +398,10 @@ void _opf_parse_navmap(struct opf *opf, xmlTextReaderPtr reader) {
} else if (xmlTextReaderNodeType(reader) == 15) {
if (item) {
+ if (! item->label) {
+ _epub_print_debug(opf->epub, DEBUG_WARNING,
+ "- missing navlabel for nav point element");
+ }
_epub_print_debug(opf->epub, DEBUG_INFO,
"adding nav point item->%s %s (d:%d,p:%d)",
item->id, item->src, item->depth, item->playOrder);
--
2.21.0