patched to fix a null ptr crash seen with baloo [release 0.2.2-2mamba;Sat Dec 21 2019]

This commit is contained in:
Silvan Calarco 2024-01-05 22:01:48 +01:00
parent e22b49f0fd
commit bb78543aa8
3 changed files with 87 additions and 1 deletions

View File

@ -0,0 +1,51 @@
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 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

View File

@ -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;

View File

@ -1,6 +1,6 @@
Name: ebook-tools Name: ebook-tools
Version: 0.2.2 Version: 0.2.2
Release: 1mamba Release: 2mamba
Summary: Tools for accessing and converting various ebook file formats Summary: Tools for accessing and converting various ebook file formats
Group: Applications/Publishing Group: Applications/Publishing
Vendor: openmamba Vendor: openmamba
@ -8,6 +8,8 @@ Distribution: openmamba
Packager: Aleph0 <aleph0@openmamba.org> Packager: Aleph0 <aleph0@openmamba.org>
URL: http://sourceforge.net/projects/ebook-tools URL: http://sourceforge.net/projects/ebook-tools
Source: http://downloads.sourceforge.net/ebook-tools/ebook-tools-%{version}.tar.gz 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 License: MIT
BuildRequires: cmake BuildRequires: cmake
## AUTOBUILDREQ-BEGIN ## AUTOBUILDREQ-BEGIN
@ -37,8 +39,12 @@ Requires: libebook = %{?epoch:%epoch:}%{version}-%{release}
A small library for accessing and converting various ebook file formats. A small library for accessing and converting various ebook file formats.
This package contains static libraries and header files need for development. This package contains static libraries and header files need for development.
%debug_package
%prep %prep
%setup -q %setup -q
%patch0 -p1
%patch1 -p2
%build %build
%cmake -d build \ %cmake -d build \
@ -70,6 +76,9 @@ This package contains static libraries and header files need for development.
%{_libdir}/libepub.so %{_libdir}/libepub.so
%changelog %changelog
* Sat Dec 21 2019 Silvan Calarco <silvan.calarco@mambasoft.it> 0.2.2-2mamba
- patched to fix a null ptr crash seen with baloo
* Sat Sep 15 2012 Silvan Calarco <silvan.calarco@mambasoft.it> 0.2.2-1mamba * Sat Sep 15 2012 Silvan Calarco <silvan.calarco@mambasoft.it> 0.2.2-1mamba
- update to 0.2.2 - update to 0.2.2