Bug 101385 - Segfault on locked documents in c++ api
Summary: Segfault on locked documents in c++ api
Status: RESOLVED MOVED
Alias: None
Product: poppler
Classification: Unclassified
Component: cpp frontend (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-12 09:39 UTC by Jeroen Ooms
Modified: 2018-08-21 10:41 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Jeroen Ooms 2017-06-12 09:39:29 UTC
If the user enters an incorrect password when reading a protected pdf via document::load_from_raw_data() a message 'Incorrect password' is printed, however the function still returns a valid *document object.

This returned object has doc->is_locked() == true and several methods are still available such as:

  doc->get_pdf_version()
  doc->info_date()
  doc->is_encrypted()
  doc->is_locked()

This is useful. What's not good is that calling any of the other methods will cause a segfault. For example:

  doc->pages()
  doc->page_layout()
  doc->metadata()
  doc->create_pag()
  doc->fonts()

Calling any of these methods on a locked document should raise a c++ exception (e.g. "error: pdf file is locked") rather than crashing.
Comment 1 Albert Astals Cid 2017-06-12 21:55:21 UTC
we don't do exceptions, just don't call any document function if is_locked returns true.

If you want to fix the crashing, patches welcome, but tbh it's not a huge priority to fix "using the API wrongly makes things crash"
Comment 2 GitLab Migration User 2018-08-21 10:41:39 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/poppler/poppler/issues/329.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.