aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFObjectHandle.cc
AgeCommit message (Collapse)Author
2019-06-22Add missing #include <cstring>Jay Berkenbilt
2019-06-21Fix bugs found by fuzz testsJay Berkenbilt
* Several assertions in linearization were not always true; change them to run time errors * Handle a few cases of uninitialized objects * Handle pages with no contents when doing form operations * Handle invalid page tree nodes when traversing pages
2019-06-21Fix sign and conversion warnings (major)Jay Berkenbilt
This makes all integer type conversions that have potential data loss explicit with calls that do range checks and raise an exception. After this commit, qpdf builds with no warnings when -Wsign-conversion -Wconversion is used with gcc or clang or when -W3 -Wd4800 is used with MSVC. This significantly reduces the likelihood of potential crashes from bogus integer values. There are some parts of the code that take int when they should take size_t or an offset. Such places would make qpdf not support files with more than 2^31 of something that usually wouldn't be so large. In the event that such a file shows up and is valid, at least qpdf would raise an error in the right spot so the issue could be legitimately addressed rather than failing in some weird way because of a silent overflow condition.
2019-06-21Change QPDFObjectHandle::pipeStreamData's encode_flags typeJay Berkenbilt
Change from unsigned long to int since we pass enumerated type values to this field.
2019-06-21Add new integer accessors to QPDFObjectHandleJay Berkenbilt
2019-06-15Give up reading objects with too many consecutive errorsJay Berkenbilt
2019-04-21Tighten isPageObject (fixes #310)Jay Berkenbilt
2019-02-01Make inline image token exactly contain the image dataJay Berkenbilt
Do not include the trailing EI, and handle cases where EI is not preceded by a delimiter. Such cases have been seen in the wild.
2019-01-31Refactor QPDFTokenizer's inline image handlingJay Berkenbilt
Add a version of expectInlineImage that takes an input source and searches for EI. This is in preparation for improving the way EI is found. This commit just refactors the code without changing the functionality and adds tests to make sure the old and new code behave identically.
2019-01-31Inline image token value ends with EI, not delimiterJay Berkenbilt
The inline image token erroneously included the delimiter that followed EI. The ObjectHandle created from it was correct.
2019-01-27Add QPDFObjectHandle::getUniqueResourceNameJay Berkenbilt
2019-01-26Handle inheritable page attributesJay Berkenbilt
Add getAttribute for handling inheritable page attributes, and fix getPageImages and annotation flattening code to use it.
2019-01-03Switch annotation flattening to use the form xobjectsJay Berkenbilt
Instead of directly putting the contents of the annotation appearance streams into the page's content stream, add commands to render the form xobjects directly. This is a more robust way to do it than the original solution as it works properly with patterns and avoids problems with resource name clashes between the pages and the form xobjects.
2019-01-01Add QPDFObjectHandle::mergeDictionary()Jay Berkenbilt
2019-01-01Add Matrix class under QPDFObjectHandleJay Berkenbilt
2018-12-22Add QPDFObjectHandle::getJSON()Jay Berkenbilt
2018-12-18Add QPDFObjectHandle::wrapInArray()Jay Berkenbilt
Wrap an object in an array if it is not already an array.
2018-06-22Treat content stream parsing errors as an error, not a warningJay Berkenbilt
If parsing content streams is treated as a warning, there is no way for a caller to know if a parsing operation has failed. This is very dangerous and will likely result in data loss when token filters are parser callbacks are in use.
2018-06-22Fix QPDFObjectHandle::shallowCopyJay Berkenbilt
It's not really a shallow copy. It just doesn't cross indirect object boundaries. The old implementation had a bug that would cause multiple shallow copies of the same object to share memory, which was not the intention.
2018-06-21Better support for creating Unicode stringsJay Berkenbilt
2018-06-21Add QPDFObjectHandle::Rectangle typeJay Berkenbilt
Provide a convenient way of accessing rectangles.
2018-04-15Limit depth of nesting in direct objects (fixes #202)Jay Berkenbilt
This fixes CVE-2018-9918.
2018-03-06Properly handle pages with no contents (fixes #194)Jay Berkenbilt
Remove calls to assertPageObject(). All cases in the library that called assertPageObject() work fine if you don't call assertPageObject() because nothing assumes anything that was being checked by that call. Removing the calls enables more files to be successfully processed.
2018-02-19More robust handling of type errorsJay Berkenbilt
Give objects descriptions and context so it is possible to issue warnings instead of fatal errors for attempts to access objects of the wrong type.
2018-02-19Push members of QPDFObjectHandle into a Members objectJay Berkenbilt
As in other cases, this is to enable adding new member variables in the future without breaking ABI compatibility.
2018-02-19Simplify TokenFilter interfaceJay Berkenbilt
Expose Pl_QPDFTokenizer, and have it do more of the work of managing the token filter's pipeline.
2018-02-19Add additional interface for filtering page contentsJay Berkenbilt
2018-02-19Implement TokenFilter and refactor Pl_QPDFTokenizerJay Berkenbilt
Implement a TokenFilter class and refactor Pl_QPDFTokenizer to use a TokenFilter class called ContentNormalizer. Pl_QPDFTokenizer is now a general filter that passes data through a TokenFilter.
2018-02-19Add coalesce contents capabilityJay Berkenbilt
2018-02-19Refactor parseContentStreamJay Berkenbilt
2018-02-19Remove redundant methodJay Berkenbilt
Remove a redundant method that was equal to another one with additional arguments. This breaks binary compatibility, but there are other ABI breaking changes in the upcoming release, so now is the time to do it.
2018-02-19Use inline image token in content parserJay Berkenbilt
2017-09-12Improve message for stream decoding errorJay Berkenbilt
Tweak the message so that we inform the user that we are mitigating data loss.
2017-08-27Fix error caught by clangJay Berkenbilt
2017-08-26Parse iteratively to avoid stack overflow (fixes #146)Jay Berkenbilt
2017-08-22Spell checkJay Berkenbilt
2017-08-21Enable finer grained control of stream decodingJay Berkenbilt
This commit adds several API methods that enable control over which types of filters QPDF will attempt to decode. It also adds support for /RunLengthDecode and /DCTDecode filters for both encoding and decoding.
2017-08-13Add page rotation (fixes #132)Jay Berkenbilt
2017-07-29Better handle split content streams (fixes #73)Jay Berkenbilt
When parsing content streams, allow content to be split arbitrarily across stream boundaries.
2017-07-28Add precheck streams capabilityJay Berkenbilt
When requested, QPDFWriter will do more aggress prechecking of streams to make sure it can actually succeed in decoding them before attempting to do so. This will allow preservation of raw data even when the raw data is corrupted relative to the specified filters.
2017-07-28Convert object parsing errors to warningsJay Berkenbilt
QPDFObjectHandle::parseInternal now issues warnings instead of throwing exceptions for all error conditions that it finds (except internal logic errors) and has stronger recovery for things like invalid tokens and malformed dictionaries. This should improve qpdf's ability to recover from a wide range of broken files that currently cause it to fail.
2017-07-26Don't interpret word tokens in content streams (fixes #82)Jay Berkenbilt
2017-07-26Handle object ID 0 (fixes #99)Jay Berkenbilt
This is CVE-2017-9208. The QPDF library uses object ID 0 internally as a sentinel to represent a direct object, but prior to this fix, was not blocking handling of 0 0 obj or 0 0 R as a special case. Creating an object in the file with 0 0 obj could cause various infinite loops. The PDF spec doesn't allow for object 0. Having qpdf handle object 0 might be a better fix, but changing all the places in the code that assumes objid == 0 means direct would be risky.
2017-07-26Fix infinite loop while reporting an error (fixes #101)Jay Berkenbilt
This is CVE-2017-9210. The description string for an error message included unparsing an object, which is too complex of a thing to try to do while throwing an exception. There was only one example of this in the entire codebase, so it is not a pervasive problem. Fixing this eliminated one class of infinite loop errors.
2015-02-21Avoid resolving arguments to RJay Berkenbilt
When checking two objects preceding R while parsing, ensure that the objects are direct. This avoids stuff like 1 0 obj containing 1 0 R 0 R from causing an infinite loop in object resolution.
2014-11-14Handle pages with no /Contents from getPageContents()Jay Berkenbilt
The spec allows /Contents to be omitted for pages that are blank, but QPDFObjectHandle::getPageContents() was throwing an exception in this case.
2013-10-18Security: replace operator[] with atJay Berkenbilt
For std::string and std::vector, replace operator[] with at. This was done using an automated process. See README.hardening for details.
2013-07-07Fix errors reported by CoverityJay Berkenbilt
Thanks to Jiri Popelka from Red Hat for sending the output of a Coverity run over qpdf.
2013-06-14Add QPDFObjectHandle::getObjGen()Jay Berkenbilt
This is safer than getObjectID() and getGeneration() for many uses.
2013-04-04Add explicit int to double castJay Berkenbilt