summaryrefslogtreecommitdiff
path: root/source
AgeCommit message (Collapse)Author
2018-02-08Add FZ_DEBUG_HTML option to EPUB parser.Tor Andersson
2018-02-08Fix 698991: The pdf_is_stream call is too generous.Tor Andersson
It should only return true for indirect references that are actually streams, not just any array/dict that is contained in a stream object.
2018-02-08Fix 698918: Use encryption when doing initial object formatting to count the ↵Tor Andersson
length.
2018-02-08Fix silly mistake in fz_output buffering.Tor Andersson
fz_write_byte forgot to write the byte after needing to flush the buffer.
2018-02-06Workaround for Android: include limits.h where SIZE_MAX is used.Sebastian Rasmussen
SIZE_MAX is surprisingly supposed to be in stdint.h, but Android headers for API levels < 21 accidentally put SIZE_MAX in limits.h. Headers for API levels >= 21 correctly moved SIZE_MAX to stdint.h. This is the situation for Android NDK r14 and earlier. Android NDK r15 and later implement a header unification strategy: all sets of headers for each API level are combined into a single set of headers covering all API levels. Any differences are expressed by #ifdeffing on __ANDROID_API__. When this was done the moving of SIZE_MAX from limits.h to stdint.h was kept and, importantly, no #ifdefs were used in limits.h/stdint.h concerning SIZE_MAX. This means that the move of SIZE_MAX was retroactively introduced for API levels < 21 in Android NDK r15 and later. For this reason whenever mupdf uses SIZE_MAX it must include both: * stdint.h (not just in order to follow the POSIX specification, but also to compile successfully using Android NDK r15 and later) * and limits.h (in order to compile successfully using Android NDK r14 and earlier) Hence these need to include both stdint.h and limits.h, because: * source/fitz/memory.c uses SIZE_MAX * source/fitz/store.c uses SIZE_MAX The mupdf header include/mupdf/fitz/system.h includes stdint.h so any file that includes system.h will automatically have stdint.h This is true for both files. limits.h on the other hand needs to be explicitly included by whomever uses SIZE_MAX. This was already done by source/fitz/store.c but not by source/fitz/memory.c, but has now been added.
2018-02-06Include limits.h where INT_MAX/INT_MIN/PATH_MAX/UINT_MAX are used.Sebastian Rasmussen
2018-02-06Bug 698986: Remember to fz_var() variable dropped in fz_catch().Sebastian Rasmussen
2018-02-06Bug 698989: Throw upon unsupported bpc when unpacking image.Sebastian Rasmussen
Previously mupdf would silently ignore this situation and leave the buffer uninitialized leading to further issues. Thanks to oss-fuzz for reporting.
2018-02-06Bug 698990: Start new run of font width only if not at end.Sebastian Rasmussen
Previously, while at the very last glyph mupdf would allocate a new array for a run of distinct glyph widths and then not drop it while leaving the function. Now a new run of font widths is only started if not at the very last glyph.
2018-02-06Bug 698988: Handle out of range predictors in filter.Sebastian Rasmussen
Thanks to oss-fuzz for reporting.
2018-02-06Remove redundant call to fz_rethrow().Sebastian Rasmussen
2018-02-06Make sure to drop colorspace upon exception drawing contents.Sebastian Rasmussen
2018-02-06Free fz_output cache buffer when dropping fz_output.Sebastian Rasmussen
2018-02-06Remove duplicated help string from mudraw.Sebastian Rasmussen
2018-02-02Bug 698891: Keep colorspace for luminosity transparency group.Sebastian Rasmussen
This was forgotten when a gray colorspace was used as a fallback in case a colorspace was never set. Thanks to oss-fuzz for reporting.
2018-02-02Signature support: add a null pdf_check_signature functionPaul Gardiner
Add a version of pdf_check_signature function that reports no support, for builds without openssl. This allows the removal of ifdefs from the apps.
2018-02-02Signature support: code-style and typo fixesPaul Gardiner
2018-02-02Signature support: decouple mupdf from the pkcs7 implementationPaul Gardiner
The mupdf build included an implimentation of the pkcs7 functions that are needed for signing documents and verifying signatures, the implementation being either an openssl-based one, or a stub that returned errors. This commit removes the pkcs7 functions from the main mupdf library. For the sake of verification, there wasn't really a need for the pkcs7 functions to be part of mupdf. It was only the checking function that used them. The checking function is now provided as a helper, outside of the main build. The openssl-based pkcs7 functions area also supplied as a helper. Users wishing to verify signatures can either use the checking function directly, or use the source on which to base their own. Document signing requires more integration between mupdf and pkcs7 because part of the process is performed at time of signing and part when saving the document. Mupdf already had a pdf_pkcs7_signer object that kept information between the two phases. That object has now been extended to include the pkcs7 functions involved in signing, and the signing function now requires such an object, rather than a file path to a certificate. The openssl-based pkcs7 helper provides a function that, given the path to a certificate, will return a pdf_pkcs7_signer object. The intention is that different implementations can be produced for different platforms, based on cryptographic routines built into the operationg system. In each case, for the sake of document signing, the routines would be wrapped up as a pdf_pkcs7_signer object.
2018-02-02Signature support: break out function for obtaining hash bytesPaul Gardiner
2018-02-02Signature support: simplify pkcs7 api by the removal of byte ranges.Paul Gardiner
Rather than provide a stream and an explicitly defined set of byte ranges within that stream, provide a stream that gives access to just the bytes in the ranges.
2018-02-02Generalise the null filter to handle more than a single range.Paul Gardiner
This is needed to simplify the way the bytes for hashing are passed to pkcs7 functions.
2018-02-02Signature support: separate pkcs7 specifics into a separate file.Paul Gardiner
Previously, pdf-pkcs7.c contained mishmash of functions required for creating and checking signatures, with no separation between the parts relating to pdf and those relating to pkcs7. This commit introduces pdf_signature.c which contains the pdf specifics, leaving pdf-pkcs7.c to be purely pkcs7 functions. This should more easily allow the use of pkcs7 solutions other than openssl. The pkcs7 api is declared in pdf-pkcs7.h. It is entirely free of mupdf specifics, other than using an fz_stream to specify the bytes to be hashed.
2018-02-02Signature support: use an enum to report errors.Paul Gardiner
Previously, errors were reported with a boolean function return with a char buffer filled out with the reason in the failure case. Now an enum is used to report the various failure cases. The function pdf_check_signature has been left as is so that existing apps will not need changing.
2018-02-02Signature support: separate the checkin of trust and digest.Paul Gardiner
The openssl function we were using checked both trust and the digest. Annoyingly, it checked trust first, so some trickery had to be used to check the digest for self-signed certificates. Now we make use of parts of the functions we were calling to provide the two parts of the check as separate functions.
2018-02-01Cast data buffer to silence compiler warning.Sebastian Rasmussen
2018-02-01Drop JPEG/J2K/JPEG-XR/PNG/TIFF colorspaces even upon exception.Sebastian Rasmussen
For TIFF it was not just the colorspace, but other data as well.
2018-02-01Do not allow out of range object numbers inside object stream.Sebastian Rasmussen
2018-02-01Skip objects inside object streams whose object ids are out of range.Sebastian Rasmussen
2018-02-01Remove redundant seek in stream.Sebastian Rasmussen
2018-02-01Use 64-bit offsets when repairing PDF objects.Sebastian Rasmussen
2018-02-01Bug 698908: Resize object use and renumbering lists after repair.Sebastian Rasmussen
Previously repair might end up increasing xref_len, but the lists were not correspodingly expanded, leading to ASAN complaints.
2018-02-01Bug 698830: Avoid recursion when loading object streams objects.Sebastian Rasmussen
If there were indirect references in the object stream dictionary and one of those indirect references referred to an object inside the object stream itself, mupdf would previously enter recursion only bounded by the exception stack. After this commit the object stream is checked if it is marked immediately after being loaded. If it is marked then we terminate the recursion at this point, if it is not marked then mark it and attempt to load the desired object within. We also take care to unmark the stream object when done or upon exception.
2018-02-01Bug 698830: Don't drop unkept stream if running out of error stack.Sebastian Rasmussen
Under normal conditions where fz_keep_stream() is called inside fz_try() we may call fz_drop_stream() in fz_catch() upon exceptions. The issue comes when fz_keep_stream() has not yet been called but is dropped in fz_catch(). This happens in the PDF from the bug when fz_try() runs out of exception stack, and next the code in fz_catch() runs, dropping the caller's reference to the filter chain stream! The simplest way of fixing this it to always keep the filter chain stream before fz_try() is called. That way fz_catch() may drop the stream whether an exception has occurred or if the fz_try() ran out of exception stack.
2018-01-31Add pdf_debug_obj function to quickly print objects from gdb command line.Tor Andersson
2018-01-31Return error token if strings are unterminated.Tor Andersson
2018-01-31Return PDF_TOK_ERROR when encountering isolated '>' and ')' characters.Tor Andersson
Also return PDF_TOK_ERROR instead of swallowing string opening quotes in pdf_lex_no_string. Also fix the repair code to not skip an extra byte whenever it scans an error token.
2018-01-31Use convenience pdf dictionary/array creation functions.Tor Andersson
2018-01-31Add convenience functions to set dict/array values by primitives.Tor Andersson
2018-01-31Rename confusing fz_stream close callback to drop.Tor Andersson
2018-01-31Fix 698886: Don't try to load non-stream XObjects.Tor Andersson
2018-01-31Don't load an xobject before the stream is final when creating new forms.Tor Andersson
2018-01-31Don't use signed int for parsing binary string into integer.Tor Andersson
2018-01-31Add buffering to fz_output.Tor Andersson
2018-01-31Reduce size of pool allocator blocks to minimize waste.Tor Andersson
A lot of EPUB pool allocated data is much smaller than the default size, leading to a lot of wasted memory.
2018-01-31Bug 698916: Indirect object numbers must be in range.Sebastian Rasmussen
2018-01-29Bug 698908: Plug PDF object leaks when decimating pages in pdfposter.Sebastian Rasmussen
The bug reports a buffer overflow, but after that was fixed this leak was reported by ASAN.
2018-01-29If drawing to one file per page in mudraw, don't use append mode.Sebastian Rasmussen
Opening in append mode was used before commit c4d3a9142761a567fce9f66946a917e087c0de67 when the same file was reopened multiple times for formats that support it. Nowadays the files is only opened once anyway so there is no reason to use append mode.
2018-01-28Bug 698942: Don't complain about external URLs being unknown.Sebastian Rasmussen
2018-01-24Make sure to drop color converter when painting shades, even upon error.Sebastian Rasmussen
2018-01-24Bug 698904: Drop pixmap only once upon error when painting shades.Sebastian Rasmussen
If fz_new_pixmap_with_bbox() threw conv would be NULL and temp would be pointing to a pixmap that would be dropped 2 times. If fz_clone_pixmap_area_with_different_seps() threw temp and conv would be pointing to the same pixmap that would be dropped 3 times.