Jay Berkenbilt
12ecd2019a
Add QPDFObjectHandle::setFilterOnWrite
2020-12-28 12:58:19 -05:00
Jay Berkenbilt
3f9191a344
Add ostream << for QPDFObjGen
2020-12-28 12:58:19 -05:00
Jay Berkenbilt
858c7b89bc
Let optimize filter stream parameters instead of making them direct
...
Also removes preclusion of stream references in stream parameters of
filterable streams and reduces write times by about 8% by eliminating
an extra traversal of the objects.
2020-12-28 12:58:19 -05:00
Jay Berkenbilt
1a62cce940
Restructure optimize to allow skipping parameters of filtered streams
2020-12-28 12:58:19 -05:00
Jay Berkenbilt
09027344b9
Refactor: separate code that determines whether to filter a stream
2020-12-28 12:58:19 -05:00
Jay Berkenbilt
39bfa01307
Implement user-provided stream filters
...
Refactor QPDF_Stream to use stream filter classes to handle supported
stream filters as well.
2020-12-28 12:58:19 -05:00
Jay Berkenbilt
cc8895078a
Add QPDFObjectHandle::makeDirect(bool allow_streams)
2020-12-26 08:48:18 -05:00
Jay Berkenbilt
573b6eb8b1
Provide qpdf write progress reporting from C API ( fixes #487 )
2020-12-20 14:43:24 -05:00
Jay Berkenbilt
2050977099
Add QPDFObjectHandle manipulation to C API
2020-11-28 19:48:07 -05:00
Jay Berkenbilt
78b9d6bfd4
Prepare 10.0.4 release
2020-11-21 13:50:02 -05:00
Jay Berkenbilt
bd79138c84
Treat direct page as runtime rather than logic error (fuzz issue 27393)
2020-11-11 09:50:43 -05:00
Jay Berkenbilt
47f4ebcdac
Ignore unused field in xref entry, avoiding range error ( fixes #482 )
2020-11-04 07:46:46 -05:00
Jay Berkenbilt
fbe40b800d
Prepare 10.0.3 release
2020-10-31 13:47:03 -04:00
Jay Berkenbilt
6971f78ff6
Fix stack overflow on direct root (fuzz issue 26761)
2020-10-31 13:10:39 -04:00
Jay Berkenbilt
ffe6af6f77
Add comments explaining the foreign object copying code
...
These are the comments I would have liked to have been able to read
while fixing #449 and #478 .
2020-10-31 12:14:26 -04:00
Jay Berkenbilt
96767fb104
Fix foreign stream copying bug ( fixes #478 )
...
This reverts an incorrect fix to #449 and codes it properly. The real
problem was that we were looking at the local dictionaries rather than
the foreign dictionaries when saving the foreign stream data. In the
case of direct objects, these happened to be the same, but in the case
of indirect objects, the object references could be pointing anywhere
since object numbers don't match up between the old and new files.
2020-10-31 12:14:26 -04:00
Jay Berkenbilt
da7540794a
Prepare 10.0.2 release
2020-10-27 11:57:48 -04:00
Jay Berkenbilt
09bd1fafb1
Improve efficiency of number to string conversion
2020-10-27 11:57:48 -04:00
Jay Berkenbilt
bcea54fcaa
Revert removal of unreadCh change for performance
...
Turns out unreadCh is much more efficient than seek(-1, SEEK_CUR).
Update comments and code to reflect this.
2020-10-27 11:57:48 -04:00
Jay Berkenbilt
b30deaeeab
Avoid merging adjacent tokens when concatenating contents ( fixes #444 )
2020-10-23 08:00:04 -04:00
Jay Berkenbilt
8a11feacc3
Avoid leak by resolving object streams more than once (fuzz issue 23642)
2020-10-22 15:39:36 -04:00
Jay Berkenbilt
30bb4c64ee
Minor code cleanup
...
* Return rather than exiting from realmain in qpdf.cc
* Remove extraneous blank line
* Don't assign temporary to const reference
2020-10-22 15:39:36 -04:00
Jay Berkenbilt
232f5fc9f3
Handle jpeg library fuzz false positives
...
The jpeg library has some assembly code that is missed by the compiler
instrumentation used by memory sanitization. There is a runtime
environment variable that is used to work around this issue.
2020-10-22 06:31:52 -04:00
Jay Berkenbilt
c1684eae91
Check for overflow in page labels (fuzz issue 23599)
2020-10-22 05:49:24 -04:00
Jay Berkenbilt
7f4a4df919
Add range_check method to QIntC
2020-10-22 05:48:40 -04:00
Jay Berkenbilt
24196c08cb
Fix loop detection error (fuzz issue 23172)
2020-10-22 05:48:35 -04:00
Jay Berkenbilt
956c8f6432
Obscure bug fix copying foreign streams in special cases ( fixes #449 )
...
Specifically, if a stream had its stream data replaced and had
indirect /Filter or /DecodeParms, it would result in non-silent loss
of data and/or internal error.
2020-10-21 19:23:23 -04:00
Jay Berkenbilt
98f6c00dad
Protect numeric conversion against user's locale ( fixes #459 )
2020-10-21 16:42:51 -04:00
Jay Berkenbilt
bed165c9fc
Stop using InputSource::unreadCh
2020-10-18 07:43:05 -04:00
Dean Scarff
153060a0c5
Check integer overflow in resolveObjectsInStream
...
Fixes a crash found by fuzzing.
2020-10-16 20:09:24 -04:00
Dean Scarff
9a3791c53b
Properly detect OPENSSL_IS_BORINGSSL
...
OPENSSL_IS_BORINGSSL is not actually set by configure, so it will be
undefined until a BoringSSL header is included. Hence the #ifdef logic
in QPDFCrypto_openssl.h would usually never apply.
This still worked because evp.h transitively included BoringSSL's
cipher.h and digest.h, but the latter are the correct (documented)
headers.
By re-ordering the includes, we can ensure the macro is defined when we
use it.
Also: fix case in the header guards.
2020-10-16 20:04:36 -04:00
Dean Scarff
2ff84aa2c9
Include detailed OpenSSL error messages
...
Fixes qpdf/qpdf#450
2020-10-16 19:58:11 -04:00
James R. Barlow
3fc7c99d02
Replace memchr with manual memory search
...
On large files with predominantly \n line endings, memchr(..'\r'..)
seems to waste a considerable amount of time searching for a line
ending candidate that we don't need.
On the Adobe PDF Reference Manual 1.7, this commit is 8x faster at
QPDF::processMemoryFile().
2020-10-16 19:57:29 -04:00
oltolm
3221022fc9
fix WindowsCryptProvider fixes #432
2020-10-16 19:56:33 -04:00
Jay Berkenbilt
ff65e272a8
Fix printf formatting for newer msvc
...
Use autoconf rather than ifdefs to determine what format string to use
for long long.
2020-10-16 07:02:23 -04:00
Jay Berkenbilt
88b8f8ec86
Remove redundant check found by lgtm.com
2020-10-15 14:47:43 -04:00
Jay Berkenbilt
26514ab731
Write linearization errors to stderr ( fixes #438 )
2020-04-29 17:33:34 -04:00
Jay Berkenbilt
92d3cbecd4
Fix warnings reported by -Wshadow=local ( fixes #431 )
2020-04-16 12:41:43 -04:00
Jay Berkenbilt
578c5ac66c
Use more references when iterating
...
When possible, use `for (auto&` or `for (auto const&` when iterating
using C++-11 style iterators.
2020-04-10 13:30:33 -04:00
Jay Berkenbilt
821a701851
Prepare 10.0.1 release
2020-04-09 11:48:26 -04:00
Jay Berkenbilt
1a7d3700a6
Fix unnecessary copies in auto iter ( fixes #426 )
...
Also switch to colon-style iteration in some cases. Thanks to Dean
Scarff for drawing this to my attention after detecting some
unnecessary copies with
https://clang.llvm.org/extra/clang-tidy/checks/performance-for-range-copy.html
2020-04-08 20:45:26 -04:00
Jay Berkenbilt
4977a7efa5
Bug fix: getStreamData should on unfilterable stream ( fixes #425 )
2020-04-08 18:52:04 -04:00
Jay Berkenbilt
1e629c278a
Prepare 10.0.0 release
2020-04-06 11:30:15 -04:00
Jay Berkenbilt
c996f4ac33
Don't include <cwchar> if not building with wchar
2020-04-06 11:23:02 -04:00
Jay Berkenbilt
77198d5310
Delegate random number generation to crypto provider ( fixes #418 )
2020-04-06 11:23:02 -04:00
Jay Berkenbilt
52749b85df
Make random data provider code thread-safe
...
This uses C++-11 thread-safe static initializers now.
2020-04-06 10:00:43 -04:00
Jay Berkenbilt
619d294e9d
Remove QUtil::srandom
2020-04-06 09:49:02 -04:00
Dean Scarff
0f2507234f
Add OpenSSL/BoringSSL crypto provider
...
Fixes qpdf/qpdf#417
2020-04-06 09:01:55 -04:00
Jay Berkenbilt
893d38b87e
Allow propagation of errors and retry through StreamDataProvider
...
StreamDataProvider::provideStreamData now has a rich enough API for it
to effectively proxy to pipeStreamData.
2020-04-05 20:07:13 -04:00
Jay Berkenbilt
7246404177
JSON: implement pattern keys in schema
2020-04-04 18:06:32 -04:00
Dean Scarff
c5c1a028cd
Use deterministic assignments for unique_id
...
Fixes qpdf/qpdf#419
2020-04-04 08:29:28 -04:00
Jay Berkenbilt
2100b4ce15
Allow qpdf to be built on systems without wchar_t ( fixes #406 )
2020-04-03 21:39:44 -04:00
Jay Berkenbilt
6a4117add9
Avoid potential segfault in warning methods
2020-04-03 21:39:20 -04:00
Jay Berkenbilt
4f3b89991b
placeFormXObject: allow control of shrink/expand ( fixes #409 )
2020-04-03 21:39:17 -04:00
Jay Berkenbilt
b76b73b229
C API: accept any non-zero value as TRUE
2020-04-03 17:33:44 -04:00
Jay Berkenbilt
54726930df
Remove redundant methods in QUtil
...
This was being saved until we had to break ABI.
2020-04-03 12:17:57 -04:00
Jay Berkenbilt
5806e5c60c
QPDFPageObjectHelper::placeFormXObject: use std::string const& ( fixes #374 )
2020-04-03 12:17:57 -04:00
Jay Berkenbilt
97de12343b
Performance: remove Members indirection for Pipeline
2020-04-03 12:17:57 -04:00
Jay Berkenbilt
bfda941519
Use an unordered map for SparseOHArray for efficiency
...
This was added in C++11.
2020-04-03 12:16:24 -04:00
Jay Berkenbilt
ee271fd2f2
Use auto for iterating over sparse array
2020-04-03 12:16:24 -04:00
Jay Berkenbilt
70665cb381
Internally use unsafeShallowCopy where we can
2020-04-03 12:16:24 -04:00
Jay Berkenbilt
38afdcea7b
Add QPDFObjectHandle::unsafeShallowCopy
2020-04-03 12:16:24 -04:00
Jay Berkenbilt
07afb668b1
Performance: remove indirection through Members for QPDFObject
2020-04-03 12:16:24 -04:00
Jay Berkenbilt
89f19b7099
Performance: remove Members indirection for QPDFObjectHandle
2020-04-03 12:16:24 -04:00
Jay Berkenbilt
dac65a21fb
Look in form XObjects when removing unreferenced resources ( fixes #373 )
...
If a page contains a form XObject, also filter the form XObject and
remove its unreferenced resources.
2020-03-31 17:39:20 -04:00
Jay Berkenbilt
278710fbe8
Refactor QPDFPageObjectHelper::removeUnreferencedResources()
...
Refactor removeUnreferencedResources to prepare for filtering form
XObjects.
2020-03-31 17:39:20 -04:00
Jay Berkenbilt
bb6768b8f0
Include header for wcslen ( fixes #405 )
2020-02-29 08:43:33 -05:00
Jay Berkenbilt
bb3137296d
Handle root /Pages pointing to other than page tree root ( fixes #398 )
2020-02-22 11:10:31 -05:00
Jay Berkenbilt
52a2e95dd5
Prepare 9.1.1 release
2020-01-26 18:49:04 -05:00
Jay Berkenbilt
57c01ef81f
In qdf mode, don't write extra XRef streams ( fixes #386 )
...
fix-qdf assumes there is exactly one XRef stream and that it is at the
end of the file.
2020-01-26 16:50:57 -05:00
Jay Berkenbilt
bbc2f8ffae
Bug fix: handle ColorSpace lookup for inline images ( fixes #392 )
...
If the value of /CS in the inline image dictionary was is key in the
page's /Resource -> /ColorSpace dictionary, properly resolve it by
referencing the proper colorspace, and not just the name, in the
external image dictionary.
2020-01-26 15:29:10 -05:00
Cloudmersive
a8b6ff5763
Fix for Windows unable to acquire crypt context with new keyset ( fixes #387 )
...
Fix is based on guidance
https://support.microsoft.com/en-us/help/238187/cryptacquirecontext-use-and-troubleshooting
and is the proper fix for #285/#286
2020-01-14 18:45:54 -05:00
Jay Berkenbilt
a44b5a34a0
Pull wmain -> main code from qpdf.cc into QUtil.cc
2020-01-14 11:40:51 -05:00
Jay Berkenbilt
ab4061f1ee
Add error detection for read_lines_from_file(FILE*)
2020-01-14 11:07:09 -05:00
Jay Berkenbilt
211a7f57be
QUtil::read_lines_from_file: optional EOL preservation
2020-01-13 11:26:18 -05:00
Jay Berkenbilt
9a398504ca
Refactor QUtil::read_lines_from_file
...
This commit adds the preserve_eol flags but doesn't implement EOL
preservation yet.
2020-01-13 09:19:53 -05:00
Jay Berkenbilt
9b0c6022d7
Prepare 9.1.0 release
2019-11-16 22:29:54 -05:00
Jay Berkenbilt
5e6dfc938e
Prepare 9.1.rc1 release
2019-11-09 22:00:53 -05:00
Jay Berkenbilt
c4478e5249
Allow odd/even modifiers in numeric range ( fixes #364 )
2019-11-09 13:23:12 -05:00
Jay Berkenbilt
5508f74603
Allow /P in encryption dictionary to be positive ( fixes #382 )
...
Even though this is disallowed by the spec, files like this have been
encountered in the wild.
2019-11-09 12:33:15 -05:00
Jay Berkenbilt
127a957aee
Allow runtime inspection/override of crypto provider
2019-11-09 09:53:42 -05:00
Jay Berkenbilt
88bedb41fe
Implement gnutls crypto provider ( fixes #218 )
...
Thanks to Zdenek Dohnal <zdohnal@redhat.com> for contributing the code
used for the gnutls crypto provider.
2019-11-09 09:53:38 -05:00
Jay Berkenbilt
cc14523440
Update autoconf to support crypto selection
2019-11-09 08:18:02 -05:00
Jay Berkenbilt
d0a53cd3ea
Fix typos in configure.ac
2019-11-09 08:18:02 -05:00
Jay Berkenbilt
c03ced09c0
Isolate source files used for native crypto
2019-11-09 08:18:02 -05:00
Jay Berkenbilt
d1ffe46c04
AES_PDF: move CBC logic from pipeline to AES_PDF implementation
2019-11-09 08:18:02 -05:00
Jay Berkenbilt
c8cda4f965
AES_PDF: switch to pluggable crypto
2019-11-09 08:18:02 -05:00
Jay Berkenbilt
bb427bd117
SHA2: switch to pluggable crypto
2019-11-09 08:18:02 -05:00
Jay Berkenbilt
eadc222ff9
Rename SHA2 implementation (non-bisectable)
2019-11-09 08:18:02 -05:00
Jay Berkenbilt
4287fcc002
RC4: switch to pluggable crypto
2019-11-09 08:18:02 -05:00
Jay Berkenbilt
0cdcd10228
Rename RC4 implementation (non-bisectable)
2019-11-09 08:18:02 -05:00
Jay Berkenbilt
ce8f9b6608
MD5: switch to pluggable crypto
2019-11-09 08:18:02 -05:00
Jay Berkenbilt
5c3e856e9f
Rename MD5 implementation (non-bisectable)
...
Just rename MD5 -> MD5_native in place so that git annotate will show
the lines as having originated there.
2019-11-09 08:18:02 -05:00
Jay Berkenbilt
2de41856a0
QPDFCryptoProvider: initial implementation
2019-11-09 08:18:02 -05:00
Jay Berkenbilt
700f5b961e
Remove int type checks -- subsumed by C++-11
2019-11-09 08:18:02 -05:00
Jay Berkenbilt
653ce3550d
Require C++-11
...
Includes updates to m4/ax_cxx_compile_stdcxx.m4 to make it work with
msvc, which supports C++-11 with no flags but doesn't set __cplusplus
to a recent value.
2019-11-09 08:18:02 -05:00
Jay Berkenbilt
9094fb1f8e
Fix two additional fuzz test cases
2019-11-03 18:59:12 -05:00
Masamichi Hosoda
5a842792b6
Parse Contents in signature dictionary without encryption
...
Various PDF digital signing tools do not encrypt /Contents value in
signature dictionary. Adobe Acrobat Reader DC can handle a PDF with
the /Contents value not encrypted.
Write Contents in signature dictionary without encryption
Tests ensure that string /Contents are not handled specially when not
found in sig dicts.
2019-10-22 16:20:21 -04:00
Masamichi Hosoda
cdc46d78f4
Add QPDFObject::getParsedOffset()
2019-10-22 16:19:06 -04:00
Masamichi Hosoda
50b329ee9f
Add QPDFWriter::getWrittenXRefTable()
2019-10-22 16:16:16 -04:00