summaryrefslogtreecommitdiff
path: root/base/scfd.c
Commit message (Collapse)AuthorAgeFilesLines
* Update postal address in file headersChris Liddell2023-04-041-3/+3
|
* Bug 705727: CCITTFax: check buffer limit before usingChris Liddell2022-08-081-3/+8
|
* Prevent buffer underrun on CCITTFaxDecodeKen Sharp2021-07-091-8/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With the file \tests_private\pdf\customer394\problems\normal_994.pdf the CCITTFaxDecode filter runs off the beginning of the 'lbuf' buffer at the end of the image data, in invert_data(). This appears to be 'something' to do with returning to the interpreter for more data, because that seems to decrement the pointer to one byte before the beginning of the buffer. This may be a red herring. What is certainly true is that we actually do write one byte of data to the byte immediately preceding the start of the buffer. The way the memory manager currently works means that corrupting this byte does not cause Ghostscript to see any problems. However when running pdfi with leak detection it writes to the 'padding' of the memory structure, corrupting it, and causing an error when the buffer is freed. We obviously should not be writing to a point before the beginning of the buffer, but I cannot make head or tail of this code. It is very complex (needlessly so IMO), makes extensive use of macros, and of course is wrapped up with the Ghostscript stream code. The result is all but incomprehensible, even to the original author I suspect! Throwing an error when we try to write to a point before the beginning of the buffer causes a number of files to exit with errors that previously did not, so its clear that there is something up here, and exiting with an error is not a fix. So given that I can't understand the code, and a naive fix is insufficient, this commit works around the problem by allocating slop at the beginning of the buffer, to match the slop already allocated at the end of the buffer. This is complicated by the fact that the code swaps the two buffers 'lbuf' and 'lprev' as it runs, and by the garbage collector which may relocate the buffers during the decoding. So in addition to allocating more memory, we need to recalculate the lpuf and lprev pointers on entry to the process routines, and when the lbuf and lprev pointers are swapped we need to swap lprevstart and lbufstart as well.
* Update copyright to 2021Chris Liddell2021-03-151-1/+1
|
* Fax Decode filter - add a simple sanity checkKen Sharp2020-12-151-0/+3
| | | | | | | | | | | | | | | | | | | | I have a test file (source unknown) e249869cf6a250726711c21fda42763c_signal_sigsegv_a418b9_5694_4827.pdf which has a number of type 3 bitmap glyphs with invalid CCITTFaxDecode parameters. The (optional) Columns key in the dictionary has an associated value of 2^32-1 in one case and an even larger value in another. The new pdfi interpreter causes a seg fault in the CCITTFaxDecoder because this breaks a 32-bit signed integer on Windows, causing the 'raster' value to be negative, when added to the memory pointer this causes us to try and read from before the beginning of the data buffer. Ghostscript's PDF interpreter doesn't trigger this because it fails much earlier and doesn't try to execute these glyphs but I'm certain it would be possible to modify the file so that it did. Adding a simple negative check and throwing an error if it is, resolves the problem.
* Rework cf_decode_2d to minimise gotos.Robin Watts2020-11-221-227/+221
|
* Reduce use of goto within cf_decode_1d.Robin Watts2020-11-221-81/+83
| | | | All gotos are now forwards. Hopefully this should assuage LGTM.
* Strip trailing whitespace from .c and .h files.Robin Watts2020-09-091-1/+1
|
* Update copyright to 2020Chris Liddell2020-04-101-1/+1
|
* Bug 702151: Avoid truncating pointers in debug code.Robin Watts2020-03-171-2/+2
| | | | | | Introduce a PRI_INTPTR and use that to consistently display pointers. We avoid using %p, as that displays inconsistently between platforms. Sometimes it does 0x%x, sometimes just %x.
* Bug 701083: Add key to treat errors as end of data when decoding images.Robin Watts2019-05-281-0/+2
| | | | | | | | | This specifically only applies to the CCITT decode filter at the moment, but the key will be in place for all image decoders to look at if required. A following commit will cause the PDF interpreter to set this key in the DecodeParms.
* Update source/header file copyright notice to 2019Chris Liddell2019-01-161-1/+1
|
* Update copyright notice with new head office address.Ken Sharp2018-01-301-3/+3
| | | | | | | | | Also update copyright dates. Remove gs_cmdl.ps as we no longer use it, and remove its entry from psfiles.htm. Remove xfonts.htm as this feature (xfont support) is long, long gone.
* Squash warnings: Warnings caused by printf specifiers.Robin Watts2016-01-041-1/+1
|
* Commit of build_consolidation branchChris Liddell2015-07-201-0/+1012
Squashed into one commit (see branch for details of the evolution of the branch). This brings gpcl6 and gxps into the Ghostscript build system, and a shared set of graphics library object files for all the interpreters. Also, brings the same configuration options to the pcl and xps products as we have for Ghostscript.