From bb78543aa820df2fa8b58cfc993d6dca2a436d70 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Fri, 5 Jan 2024 22:01:48 +0100 Subject: [PATCH] patched to fix a null ptr crash seen with baloo [release 0.2.2-2mamba;Sat Dec 21 2019] --- ebook-tools-0.2.2-crash-fix.patch | 51 ++++++++++++++++++++++++++++ ebook-tools-0.2.2-fix_null_ptr.patch | 26 ++++++++++++++ ebook-tools.spec | 11 +++++- 3 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 ebook-tools-0.2.2-crash-fix.patch create mode 100644 ebook-tools-0.2.2-fix_null_ptr.patch diff --git a/ebook-tools-0.2.2-crash-fix.patch b/ebook-tools-0.2.2-crash-fix.patch new file mode 100644 index 0000000..2389d29 --- /dev/null +++ b/ebook-tools-0.2.2-crash-fix.patch @@ -0,0 +1,51 @@ +From 93ebf942a90f9c95797838f9adab94bc0378671c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Stefan=20Br=C3=BCns?= +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 a/ebook-tools/src/libepub/epub.c b/ebook-tools/src/libepub/epub.c +index d085503..a259d9d 100644 +--- a/ebook-tools/src/libepub/epub.c ++++ b/ebook-tools/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 a/ebook-tools/src/libepub/opf.c b/ebook-tools/src/libepub/opf.c +index 6851db2..09bce9e 100644 +--- a/ebook-tools/src/libepub/opf.c ++++ b/ebook-tools/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 + diff --git a/ebook-tools-0.2.2-fix_null_ptr.patch b/ebook-tools-0.2.2-fix_null_ptr.patch new file mode 100644 index 0000000..dabeb9e --- /dev/null +++ b/ebook-tools-0.2.2-fix_null_ptr.patch @@ -0,0 +1,26 @@ +diff -ur ebook-tools-0.2.2.0/src/libepub/linklist.c ebook-tools-0.2.2/src/libepub/linklist.c +--- ebook-tools-0.2.2.0/src/libepub/linklist.c 2012-09-04 07:32:32.000000000 -0700 ++++ ebook-tools-0.2.2/src/libepub/linklist.c 2019-09-19 17:38:55.499059141 -0700 +@@ -115,7 +115,8 @@ + + while ((Compare = (List->compare)(List->Current->Data, Data)) != 0) { + List->Current = List->Current->Next; +- if (List->Current == NULL) ++ if ((List->Current == NULL) || ++ (List->Current->Data == NULL)) + return NULL; // end of list + } + } +diff -ur ebook-tools-0.2.2.0/src/libepub/list.c ebook-tools-0.2.2/src/libepub/list.c +--- ebook-tools-0.2.2.0/src/libepub/list.c 2012-09-04 07:32:32.000000000 -0700 ++++ ebook-tools-0.2.2/src/libepub/list.c 2019-09-19 17:33:49.780068574 -0700 +@@ -137,6 +137,9 @@ + + int _list_cmp_label_by_lang(struct tocLabel *t1, struct tocLabel *t2) { + ++ if ((t1 == NULL) || (t2 == NULL)) ++ return 0; ++ + if (! t1->lang || ! t2->lang) + return 0; + diff --git a/ebook-tools.spec b/ebook-tools.spec index 7edcd10..dab6541 100644 --- a/ebook-tools.spec +++ b/ebook-tools.spec @@ -1,6 +1,6 @@ Name: ebook-tools Version: 0.2.2 -Release: 1mamba +Release: 2mamba Summary: Tools for accessing and converting various ebook file formats Group: Applications/Publishing Vendor: openmamba @@ -8,6 +8,8 @@ Distribution: openmamba Packager: Aleph0 URL: http://sourceforge.net/projects/ebook-tools Source: http://downloads.sourceforge.net/ebook-tools/ebook-tools-%{version}.tar.gz +Patch0: ebook-tools-0.2.2-fix_null_ptr.patch +Patch1: ebook-tools-0.2.2-crash-fix.patch License: MIT BuildRequires: cmake ## AUTOBUILDREQ-BEGIN @@ -37,8 +39,12 @@ Requires: libebook = %{?epoch:%epoch:}%{version}-%{release} A small library for accessing and converting various ebook file formats. This package contains static libraries and header files need for development. +%debug_package + %prep %setup -q +%patch0 -p1 +%patch1 -p2 %build %cmake -d build \ @@ -70,6 +76,9 @@ This package contains static libraries and header files need for development. %{_libdir}/libepub.so %changelog +* Sat Dec 21 2019 Silvan Calarco 0.2.2-2mamba +- patched to fix a null ptr crash seen with baloo + * Sat Sep 15 2012 Silvan Calarco 0.2.2-1mamba - update to 0.2.2