Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

epub: add fallback for malformed epub files in check_mime_type #571

Merged
merged 1 commit into from
Nov 17, 2022

Conversation

rbuj
Copy link
Contributor

@rbuj rbuj commented Aug 7, 2022

fix #325

Copy link
Member

@lukefromdc lukefromdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the build warnings I get from compiling epub-document.c with this applied are from parts of the code which are NOT changed and shared with master, so looks like no new build warnings. A test epub file opens fine with this installed,and no runtime warnings show up in terminal.

I have not had enough experience with epub files to run into the original issue, but this code does seem to work with a known good test file. Security-wise, refusing to open malformed files can block an attack on someone's machine. Downside is it may take a bit less corruption to make a file impossible to open.

Probably safer than trusting a file extension which a malicious document author can easily slap on to anything.

@lukefromdc lukefromdc requested a review from a team August 8, 2022 02:51
@lukefromdc
Copy link
Member

A rebase of this against current master opened the previously referrred to test file from the issue, though being malformed internal elements of it beyond the picture were not found. They were not found with just trusting the file extension either, and that's potentially less safe, so that's the fault of the file, not this effort to get partially usable epub files to open.

Another test file
https://github.com/IDPF/epub3-samples/releases/download/20170606/cc-shared-culture.epub
from the older segfault issue fixed by another PR opened fine with this applied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EPUB fails to open
2 participants