Bug 407140 - Crash, QTextDocument chokes on input and ends up with negative pagecounts
Summary: Crash, QTextDocument chokes on input and ends up with negative pagecounts
Status: RESOLVED FIXED
Alias: None
Product: okular
Classification: Applications
Component: EPub backend (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-05-01 22:44 UTC by Stefan Brüns
Modified: 2019-06-04 09:50 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Problematic PDF (550.42 KB, application/epub+zip)
2019-05-01 22:44 UTC, Stefan Brüns
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Brüns 2019-05-01 22:44:23 UTC
Created attachment 119786 [details]
Problematic PDF

SUMMARY
The EPub generator wraps the page content with a html table, and after QTextDocument::setHtml(...) the pageCount() is -42192. This later leads to crashes when the page number is used as an array index.

Removing the wrapping table from the firstpage code path avoids the bad behavior. 

The problematic PDF is the one from https://bugs.kde.org/show_bug.cgi?id=406116, but with the bad navPoint entries removed. According to EPubCheck, the fixed file is wellformed.

STEPS TO REPRODUCE
1. Try to open the attached EPub with okular.

OBSERVED RESULT
Crash

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: openSUSE Tumbleweed 20190428
KDE Plasma Version: 19.04.00
KDE Frameworks Version: 5.57
Qt Version: 5.12

ADDITIONAL INFORMATION
Comment 1 Albert Astals Cid 2019-05-08 22:55:58 UTC
That's not a pdf ;)

This is most probably a duplicate of 406738

Do you have time to check?
Comment 2 Stefan Brüns 2019-05-09 22:43:33 UTC
(In reply to Albert Astals Cid from comment #1)
> That's not a pdf ;)
> 
> This is most probably a duplicate of 406738
> 
> Do you have time to check?

The backtrace is the same.
Comment 3 Albert Astals Cid 2019-05-22 22:25:12 UTC
Git commit 9f98c010691ed73d11c83a1694823aba60b12e32 by Albert Astals Cid, on behalf of Stefan Brüns.
Committed on 22/05/2019 at 22:24.
Pushed by aacid into branch 'Applications/19.04'.

[EPubGenerator] Avoid crashes due to bogus wrapping of content in table

Summary:
QTextDocument chokes badly when a some documents are wrapped inside
a table, returning e.g. a pagecount of -41292 afterwards.

On the downside, this removes any padding from the page. On the upside,
it removes any padding from the page.
Related: bug 406738, bug 406116

Reviewers: #okular

Subscribers: okular-devel

Tags: #okular

Differential Revision: https://phabricator.kde.org/D20949

M  +1    -7    generators/epub/converter.cpp

https://commits.kde.org/okular/9f98c010691ed73d11c83a1694823aba60b12e32
Comment 4 Christoph Feck 2019-06-04 09:50:41 UTC
https://bugreports.qt.io/browse/QTBUG-73730