aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDF_linearization.cc
AgeCommit message (Collapse)Author
2022-08-31Replace calls to QPDFObjectHandle::Factory::newIndirect where possiblem-holger
2022-08-01Add QPDF::getObject to replace getObjectByObjGen and getObjectByIDm-holger
For consistency with similar methods, e.g. replaceObject.
2022-07-26Code tidy : replace 0 with nullptr or truem-holger
2022-07-24Revert making second parameter of QPDFObjGen::QPDFObjGen optionalm-holger
Also, change test for QPDFObjGen::isIndirect to obj != 0. Delete comment from commit afd35f9.
2022-07-24QPDFObjGen : tidy QPDF private methodsm-holger
Change method signatures to use QPDFObjGen. Use QPDFObjGen methods where possible. Remove redundant QPDF::objGenToIndirect.
2022-07-24QPDFObjGen : tidy QPDFObjectHandle private methodsm-holger
Change method signature to use QPDFObjGen.
2022-07-24QPPFObjGen : tidy QPDF::readObjectAtOffsetm-holger
Change method signature to use QPDFObjGen.
2022-07-24Clarify intent in readObjectAtOffsetJay Berkenbilt
Rather than using object id -1 to mean "don't care", use object ID 0, and clarify the difference between that use and indication of a direct object.
2022-06-18QPDF, QPDFJob: use QPDFLogger instead of custom output streamsJay Berkenbilt
2022-05-21Code clean up: use range-style for loops wherever possiblem-holger
Remove variables obsoleted by commit 4f24617.
2022-05-04Remove remaining incorrect assert calls from implementationJay Berkenbilt
2022-04-30Code clean up: use range-style for loops wherever possibleJay Berkenbilt
Where not possible, use "auto" to get the iterator type. Editorial note: I have avoid this change for a long time because of not wanting to make gratuitous changes to version history, which can obscure when certain changes were made, but with having recently touched every single file to apply automatic code formatting and with making several broad changes to the API, I decided it was time to take the plunge and get rid of the older (pre-C++11) verbose iterator syntax. The new code is just easier to read and understand, and in many cases, it will be more effecient as fewer temporary copies are being made. m-holger, if you're reading, you can see that I've finally come around. :-)
2022-04-09Replace PointerHolder with std::shared_ptr in library sources onlyJay Berkenbilt
(patrepl and cleanpatch are my own utilities) patrepl s/PointerHolder/std::shared_ptr/g {include,libqpdf}/qpdf/*.hh patrepl s/PointerHolder/std::shared_ptr/g libqpdf/*.cc patrepl s/make_pointer_holder/std::make_shared/g libqpdf/*.cc patrepl s/make_array_pointer_holder/QUtil::make_shared_array/g libqpdf/*.cc patrepl s,qpdf/std::shared_ptr,qpdf/PointerHolder, **/*.cc **/*.hh git restore include/qpdf/PointerHolder.hh cleanpatch ./format-code
2022-04-04Programmatically apply new formatting to codeJay Berkenbilt
Run this: for i in **/*.cc **/*.c **/*.h **/*.hh; do clang-format < $i >| $i.new && mv $i.new $i done
2022-02-08WHITESPACE ONLY -- expand tabs in source codeJay Berkenbilt
This comment expands all tabs using an 8-character tab-width. You should ignore this commit when using git blame or use git blame -w. In the early days, I used to use tabs where possible for indentation, since emacs did this automatically. In recent years, I have switched to only using spaces, which means qpdf source code has been a mixture of spaces and tabs. I have avoided cleaning this up because of not wanting gratuitous whitespaces change to cloud the output of git blame, but I changed my mind after discussing with users who view qpdf source code in editors/IDEs that have other tab widths by default and in light of the fact that I am planning to start applying automatic code formatting soon.
2022-02-07Update for clean compile with POINTERHOLDER_TRANSITION=2Jay Berkenbilt
2022-02-07Replace PointerHolder arrays with shared_ptr arrays where possibleJay Berkenbilt
Replace PointerHolder arrays wherever it can be done without breaking ABI.
2022-02-04PointerHolder: deprecate getPointer() and getRefcount()Jay Berkenbilt
Use get() and use_count() instead. Add #define NO_POINTERHOLDER_DEPRECATION to remove deprecation markers for these only. This commit also removes all deprecated PointerHolder API calls from qpdf's code except in PointerHolder's test suite, which must continue to test the deprecated APIs.
2021-12-10Handle bitstream overflow errors more gracefully (fixes #581)Jay Berkenbilt
* Make it a runtime error, not a logic error * Include additional information * Capture it properly in checkLinearization
2020-04-29Write linearization errors to stderr (fixes #438)Jay Berkenbilt
2020-04-16Fix warnings reported by -Wshadow=local (fixes #431)Jay Berkenbilt
2019-06-25Convert previously overlooked static cast to QIntCJay Berkenbilt
2019-06-23Treat all linearization errors as warningsJay Berkenbilt
This also reverts the addition of a new checkLinearization that distinguishes errors from warnings. There's no practical distinction between what was considered an error and what was considered a warning.
2019-06-22qpdf: exit 3 for linearization warnings without errors (fixes #50)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-01-07Fix integer overflow in large file testJay Berkenbilt
2019-01-04Don't call assert while checking linearization data (fixes #209, #231)Jay Berkenbilt
Instead of calling assert for problems found during checking linearization data, throw an exception which is later caught and issued as an error. Ideally we would handle errors more robustly, but this is still a significant improvement.
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.
2017-08-22Push QPDF member variables into a nested classJay Berkenbilt
Pushing member variables into a nested class enables addition of new member variables without breaking binary compatibility.
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-11Find lindict without PCREJay Berkenbilt
2017-08-11Implement findFirst and findLast in InputSourceJay Berkenbilt
Preparing to refactor some pattern searching code to use these instead of their own memchr loops. This should simplify the code that replaces PCRE.
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-10-10Replace some assertions with std::logic_errorJay Berkenbilt
Ideally, the library should never call assert outside of test code, but it does in several places. For some cases where the assertion might conceivably fail because of a problem with the input data, replace assertions with exceptions so that they can be trapped by the calling application. This commit surely misses some cases and replaced some cases unnecessarily, but it should still be an improvement.
2013-10-10Security: avoid pre-allocating vectors based on file dataJay Berkenbilt
In places where std::vector<T>(size_t) was used, either validate that the size parameter is sane or refactor code to avoid the need to pre-allocate the vector.
2013-10-10Security: better bounds checks for linearization dataJay Berkenbilt
The faulty code was only used during explicit checks of linearization data. Those checks are not part of normal reading or writing of PDF files.
2013-06-15Handle /Outlines dictionary being a direct objectJay Berkenbilt
Even though this case is not valid according to the spec, it has been seen, and caused an internal error.
2013-06-14Use QPDFObjectHandle::getObjGen() where appropriateJay Berkenbilt
In internal code and examples, replace calls to getObjectID() and getGeneration() with calls to getObjGen() where possible.
2013-06-14Promote QPDF::ObjGen to top-level object QPDFObjGenJay Berkenbilt
2013-03-04Remove all old-style casts from C++ codeJay Berkenbilt
2012-09-06Reset state in QPDF::calculateLinearizationDataJay Berkenbilt
This makes it possible to use two different writers to write linearized files from the same QPDF object.
2012-06-24Fix and test support for files >= 4 GBJay Berkenbilt
2012-06-22Use qpdf_offset_t in place of off_t in public APIs.Jay Berkenbilt
off_t is used internally only when needed to talk to standard libraries. This requires that the "long long" type be supported by the compiler.
2012-06-20ABI change: fix use of off_t, size_t, and integer typesJay Berkenbilt
Significantly improve the code's use of off_t for file offsets, size_t for memory sizes, and integer types in cases where there has to be compatibility with external interfaces. Rework sections of the code that would have prevented qpdf from working on files larger than 2 (or maybe 4) GB in size.
2011-12-28Don't declare any PCRE objects static.Jay Berkenbilt
2011-08-11enhance PointerHolder so that it can explicitly be told to use delete [] ↵Jay Berkenbilt
instead of delete, thus making it useful to run valgrind over qpdf during its test suite
2011-05-07remove unused offset variableJay Berkenbilt
git-svn-id: svn+q:///qpdf/trunk@1056 71b93d88-0707-0410-a8cf-f5a4172ac649
2011-01-31handle files with object 0 as a real objectJay Berkenbilt
git-svn-id: svn+q:///qpdf/trunk@1049 71b93d88-0707-0410-a8cf-f5a4172ac649
2010-10-01setOutputStreamsJay Berkenbilt
git-svn-id: svn+q:///qpdf/trunk@1035 71b93d88-0707-0410-a8cf-f5a4172ac649