summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2014-01-16Bug 694894: Avoid throwing away an object while in use.Robin Watts
When we call to execute a pattern, we clear out the pdf_csi (the interpreter state). This involves clearing the stack and throwing away the record of the object we have just parsed. Unfortunately, when filling glyphs with a pattern, that object is still in use. We therefore amend the pdf_run_contents_stream to safely stash the object away and restore it afterwards. This solves this problem, and protects us against any other similar problems that might also arise. This solves: b8e2b57991896bf8120215cfbf7b54bb_asan_heap-uaf_86064f_2362_2587.pdf Thanks to Mateusz Jurczyk and Gynvael Coldwind of the Google Security Team for providing the example files.
2014-01-15Remove repeated NDEBUG in release preprocessor list in WinRT projectsMichael Vrhel
2014-01-15Clearer division in WinRT vs std C++ codeMichael Vrhel
To share as much code as possible between the Windows 8 app, windows phone app and Windows desktop app, remove dependencies of Platform and Windows::Foundation in files that interface to mupdf and replace with C/C++ std methods.
2014-01-15Minor changes for windows 8 store validationMichael Vrhel
2014-01-15Fixes for Windows 8.1 store validationMichael Vrhel
We have to clean up the DirectX memory during suspension. Also define NDEBUG for the release cases so that we avoid the use of OutputDebugStringA in error.c which is not allowed in Windows store apps.
2014-01-13Avoid rendering errors caused by linejoins on tiny distances.Robin Watts
If we perform a linejoin that ends up being over an impossibly small distance, we can get a rendering error. This is caused by trying to calculate scale = linewidth/sqrtf(len), where len < FLT_EPSILON. Avoid this by rearranging the code slightly - no extra calculations required. Also given that sn == bn at all times within the stroking code, just remove bn. Credit for spotting this problem goes to Simon for tracking the problem with rounding_artifact_due_to_closepath.pdf. My fix just fixes the problem at a lower level than his does.
2014-01-13tolerate overlong colorspace lookup stringsSimon Bünzli
At http://code.google.com/p/sumatrapdf/issues/detail?id=2477 , there's a document which has an indexed colorspace whose lookup string contains a trailing character. That character can be safely ignored without rejecting everything depending on such a colorspace.
2014-01-13Bug 694890: Solve valgrind issues/SEGV due to use of invalid pixmapRobin Watts
fz_draw_clip_text changes the value of 'state' during a loop. The 'if (glyph)' part of the loop assumes that it points to gstate[top-1] where the 'path' part of the loop changes it to point to gstate[top]. If we render a "non glyph" glyph, then a "glyph" glyph, we will access an invalid state. This can cause a draw_glyph call on an invalid destination bitmap. The fix is simply not to reset state. Thanks to Mateusz Jurczyk and Gynvael Coldwind of the Google Security Team for providing the fuzzing files.
2014-01-13Bug 694851: enhance fz_load_system_fontSimon Bünzli
For SumatraPDF, the following changes are required: * fz_load_system_font is called from pdf_load_builtin_font as well so that Arial, Courier New, etc. can be loaded from the system instead of their Nimbus replacements. In order to distinguish between calls from pdf_load_builtin_font and pdf_load_substitute_font, an is_substitute argument is added. * fz_load_system_cjk_font is added and called from pdf_load_substitute_cjk_font so that a better replacement font can be loaded instead of DroidSansFallback. * Both fz_load_system_font and fz_load_system_cjk_font return fz_font* instead of fz_buffer* so that implementers aren't required to load fonts into memory (SumatraPDF uses fz_new_font_from_file for system fonts). In addition to that, fz_load_system_font_func is renamed to fz_load_system_font_funcs since it now accepts two functions, and the PDF_ROS_* constants are renamed to FZ_ADOBE_* (collection names aren't passed as const char* so that implementers know which collections to expect). For convenience, fz_load_*_font also never throws since currently all callers have further fallbacks available.
2014-01-13verify that openjpeg actually allocates dataSimon Bünzli
This can be seen e.g. in: 5db811ac25ef543fd0cfa0873e155329_signal_sigsegv_c9b60f_9636_76.pdf Thanks to Mateusz Jurczyk and Gynvael Coldwind of the Google Security Team for providing the example files.
2014-01-13More fixes for PDF clean.Robin Watts
Avoid negative indirections. Don't make indirections to objects that aren't going to be used. Also improve pdf-write.c so that it doesn't call renumberobj on objs that are going to be dropped.
2014-01-13Memento fixes for working with valgrind.Robin Watts
Remember to make blocks defined before writing/reading them.
2014-01-13iOS: attach the slider to the toolbar differently for iOS 7Paul Gardiner
Under iOS 7, the slider becomes inoperable when included a toolbar item in the standard way. Instead just add it as a subview, being careful to also remove it to avoid multiple copies
2014-01-10iOS: animate the custom buttons used for the iPhone buildPaul Gardiner
2014-01-10Bug 694889: Fix valgrind issues due to empty indexed spaces.Robin Watts
If indexed spaces are empty (or truncated) we use garbage values when they are read. Spot this and pad with 0s to at least be consistent. Fixes: 013b2dcbd0207501e922910ac335eb59_asan_heap-oob_a59696_5952_500.pdf 5440f8bc8af12e5f7050e59b7ee008cd_asan_heap-oob_a59dd9_5952_500.pdf fa8c712b03a7b02d6a12856ce042a44e_signal_sigsegv_a59b06_5847_493.pdf Thanks to Mateusz Jurczyk and Gynvael Coldwind of the Google Security Team for providing the fuzzing files.
2014-01-10iOS: correctly handle document changes that may affect several pagesPaul Gardiner
Interaction with forms may change several pages, so all pages currently represented by view need updating.
2014-01-10iOS: better structure the page update codePaul Gardiner
2014-01-10iOS: on iPhone use custom buttons to accommodate shortage of spacePaul Gardiner
Otherwise, in portrait mode, there isn’t enough room for all five buttons and some are not displayed.
2014-01-10Solve SEGV in mutool clean with fuzzed file.Robin Watts
While attempting to debug a valgrind issue with: 013b2dcbd0207501e922910ac335eb59_asan_heap-oob_a59696_5952_500.pdf I found that mutool -difggg on it failed with a SEGV. This is due to us parsing an array with a large invalid indirection in it (e.g. [123456789 0 R]) and then the renumbering code assuming this is valid and accessing off the end of an array.
2014-01-10Bug 694885: Avoid stack overflow in ps_run.Robin Watts
The ifelse and if operators require special parsing where we convert ps function streams to bytecode. If a malformed stream presents if or ifelse without being preceded by the appropriate { ...} blocks then throw an error. This avoids us potentially calling ps_run recursively in an infinite loop as happens with the test file in this bug. 5f091df77f6600d0927dc36777db2b93_signal_sigabrt_7ffff6d59425_6762_5545.pdf Thanks to Mateusz Jurczyk and Gynvael Coldwind of the Google Security Team for providing the fuzzing files.
2014-01-10Bug 694879: Fix SEGV in draw-simple-scale.Robin Watts
Problems caused by the fact that -0x8000000 = 0x80000000. Sidestep the problem for all coords where floats cannot accurately represent them.
2014-01-10Fix build_filter_chain not to leak if pdf_array_get fails.Robin Watts
In the existing code, if build_filter fails, chain will be freed. If pdf_array_get fails however, it will leak. Rectify this. No specific bug or example file, just observation arising from discussions about previous commit.
2014-01-09Add tiling into the DirectX printing code.Michael Vrhel
The tiling in x and y is needed to ensure that we can print at high resolutions with devices that have smaller bit map sizes (e.g. the surface). Banding only in the y dimension like we often do is not sufficient. Also fix an open with file association bug that must of occurred with the transition to 8.1 And update WinRT solution for recent changes in mupdf code. This includes the addition of a few new files and the document type registration.
2014-01-09prevent two further heap access violationsSimon Bünzli
pdf_open_raw_renumbered_stream and pdf_open_image_stream both have the same issue that 98a111c8e49916f8f5ac21d11f4627540f9ddd49 fixes.
2014-01-09Bug 694878: Fix SEGV due to double freeRobin Watts
When constructing a filter chain, we pass ownership of 'chain' inwards. This means we need to be careful not to double close chain. This fixes: 5df97f8539d31745f1c45cc9e1468825_asan_heap-oob_a59afe_1862_225.pdf a736faf6f4a34b7ad8eff207ba52aa57_asan_heap-oob_a59dd9_5744_4860.pdf Thanks to Mateusz Jurczyk and Gynvael Coldwind of the Google Security Team for providing the fuzzing files.
2014-01-09Add -o option for mutool show.Tor Andersson
Windows doesn't like redirecting binary output, so add an explicit filename argument.
2014-01-09Remove comment header blurb from ios files.Tor Andersson
2014-01-09Update copyright date.Tor Andersson
2014-01-09iOS: save changes on returning to the libraryPaul Gardiner
Also change the way the back button works, using an explicit action, rather than relying on the navigation controller. Doing so allowed an alert dialog to be displayed asking if document changes should be discarded or saved. It also allowed the word-based button to be replaced by an icon-based one, which saves space (important for iPod and iPhone). We may want to also save on other occasions, but this at least provides some way to do so.
2014-01-08Update curl build to avoid warning when linking windows release builds.Robin Watts
2014-01-08fuzzing fix for null colorspace derefence.Robin Watts
Bad annotation appearance streams can cause font_recs to have invalid values in. Avoid this partly by hardening the code against duff values, and partly by setting sane defaults before the parsing. This can be seen in: 33bfbe117bfef7fafc3f927acf50a2e7_signal_sigsegv_81dd96_6257_5205.pdf Thanks to Mateusz Jurczyk and Gynvael Coldwind of the Google Security Team for providing the example files.
2014-01-08Fix fuzzing bug due to float representation limitations.Robin Watts
The gel bbox was being stored internally as floats (despite only holding ints). This means that as numbers get large the bbox can become approximate, rather than exact. If the bbox becomes smaller than it should, this causes crashes in the scanline filling code. This is seen with: tests_private/fuzzing/mupdf2/17f8aee51ac776994af0b36195cdadd7_signal_sigsegv_5607be_7308_5912.pdf The solution is simply to use ints rather than floats. Thanks to Mateusz Jurczyk and Gynvael Coldwind of the Google Security Team for providing the example files.
2014-01-08Fuzzing fix: Overrun in fz_predict_pngRobin Watts
If a file specifies a silly number of bpp in the PNG predictor it can overrun a buffer. This was shown by: tests_private/fuzzing/mupdf2/013b2dcbd0207501e922910ac335eb59_*.pdf but no longer shows up due to Simons earlier fix. Following discussion we still think it's worth having this fix in, as truncated data streams can cause len < bpp. Possibly we should throw an error here, but I think that's not necessary as we will return the short length, and the image reading code will notice that the image is truncated already. Thanks to Mateusz Jurczyk and Gynvael Coldwind of the Google Security Team for providing the fuzzing files.
2014-01-08prevent heap access violation in pdf_cache_objectSimon Bünzli
pdf_load_obj_stm may resize the xref if it finds further objects in the stream, that might however invalidate any pdf_xref_entry hold such as the one in pdf_cache_object. This can be seen e.g. with 7ac3ad9ddad98d10b947a43cf640062f_asan_heap-uaf_930b78_1007_1675.pdf Thanks to Mateusz Jurczyk and Gynvael Coldwind of the Google Security Team for providing the example files.
2014-01-08sanitize crypt revision in pdf_new_cryptSimon Bünzli
(Second part of Simons patch - apologies for missing this the first time). This correctly enables the sanitization of the key length needed for 90db34f64037e2a8a5c3b6a518ba4153_asan_heap-oob_9b117e_1197_1802.pdf Thanks to Mateusz Jurczyk and Gynvael Coldwind of the Google Security Team for providing the example files.
2014-01-08sanitize number of columns in fz_open_faxdSimon Bünzli
If columns is quite close to INT_MAX, the column index max overflow in find_changing which causes an access violation in the next getbits. This happens e.g. with 0c76a20163f30ea8ec860c4e588ce337_signal_sigsegv_5e7b28_9115_7127.pdf
2014-01-08sanitize crypt revision in pdf_new_cryptSimon Bünzli
This correctly enables the sanitization of the key length needed for 90db34f64037e2a8a5c3b6a518ba4153_asan_heap-oob_9b117e_1197_1802.pdf
2014-01-08sanitize values in fz_open_predictSimon Bünzli
This fixes a NULL pointer dereference in 2192b04848b2d8210d1a33e3ddeb2742_asan_heap-oob_a5a57d_2745_2844.pdf Also, replace MAXC with FZ_MAX_COLORS.
2014-01-07iOS: remove search-bar-transparency hackPaul Gardiner
Doesn’t work in iOS 7.1: removes the the whole text view
2014-01-07iOS: don’t allow hiding of the navigation bar when it is other than at the ↵Paul Gardiner
root menu Seems more natural and avoids cases where tapping doesn’t bring the bar back, hence trapping the user in one of the submodes.
2014-01-07iOS: protect against crashing when handling accented chars in choice fieldsPaul Gardiner
Use conversion assuming ascii as a fallback to assuming utf8. The library should be converting to utf8 but doesn’t currently.
2014-01-07iOS: update the form filling dialogs to avoid the keyboard hiding the buttonsPaul Gardiner
Also bring up the keyboard automatically
2014-01-07iOS: fix for document handlersPaul Gardiner
2014-01-07Introduce 'document handlers'.Robin Watts
We define a document handler for each file type (2 in the case of PDF, one to handle files with the ability to 'run' them, and one without). We then register these handlers with the context at startup, and then call fz_open_document... as usual. This enables people to select the document types they want at will (and even to extend the library with more document types should they wish).
2014-01-06Bug 694869: Fix indetermisms with broken PNG files.Robin Watts
This bug shows 2 problems with our data handling. Firstly, if a zip file entry has less data in the stream than it is declared to have, we would leave the end of the data uninitialised. We now put out a warning, and blank it with zeros. Secondly, if the PNG decompression fails to decode enough data, we don't notice. Now we give a warning and blank the remaining pixels.
2014-01-06reuse JBIG2GlobalsSimon Bünzli
Certain optimized documents use a rather large common symbol dictionary for all JBIG2 images. Caching these JBIG2Globals speeds up loading and rendering of such documents.
2014-01-06show jbig2dec warnings/errors in stderrSimon Bünzli
This helps debugging issues with JBIG2 images. Conflicts: source/fitz/filter-jbig2.c
2014-01-06add stub files for JPEG-XR supportSimon Bünzli
See SumatraPDF's repo for a Windows-only implementation using WIC.
2014-01-06tolerate slightly broken page treesSimon Bünzli
At https://code.google.com/p/sumatrapdf/issues/detail?id=2460 , there's a file with missing /Type keys in the page tree nodes. In that case, leaf nodes and intermediary nodes have to be distinguished in a different way.
2014-01-06fix MSVC warnings C4054 and C4152Simon Bünzli
These warnings are caused by casting function pointers to void* instead of proper function types.