summaryrefslogtreecommitdiff
path: root/jbig2dec
Commit message (Collapse)AuthorAgeFilesLines
* Update postal address in file headersChris Liddell2023-04-0441-129/+133
|
* jbig2dec: Update contact information and fix typo.Sebastian Rasmussen2021-08-103-3/+3
|
* jbig2dec: Improve reporting from custom allocator that limits memory use.Sebastian Rasmussen2021-08-091-20/+45
|
* jbig2dec: Avoid underflow in custom allocator.Sebastian Rasmussen2021-08-091-29/+22
|
* jbig2dec: Use silent rules when building as a separate project.Sebastian Rasmussen2021-08-091-0/+1
|
* jbig2dec: Do not redefine inline until all systemwide headers are included.Sebastian Rasmussen2021-08-092-5/+5
| | | | | | | | | | | | | | | | | | | | | | | When cross-compiling jbig2dec like so: ./configure --host=i686-w64-mingw32 --disable-static && make clean && make ... you get linker errors about multiple definintions of llabs, lltoa, etc. The reason for this is that the inline keyword has been redfined to the empty string. After that has been done in jbig2.h it includes jbig2_priv.h which includes memento.h which includes stdlib.h. The inline redefinition causes all declarations in stdlib.h to then be done without inline causing the functions to be present at least twice in in the set of object files. The redefine was introduced in commit cb456c92a550e1af70a4e268b2f5b02f2df5b8c6 Since jbig2.h is jbig2dec's public header this would affect any program that includes jbig2.h and then includes system-wide headers after that. This commit circumvents the issue by moving the inline redefine from the end of the public jbig2.h header to later in the internal jbig2_priv.h header, immediately after memento.h has been included. This way the redefine still affects any jbig2dec internal source code, but not any users of jbig2dec.
* Update copyright to 2021Chris Liddell2021-03-1541-41/+41
|
* Bug 703653: jbig2dec: Use correct freeing function for JBIG2 images.Sebastian Rasmussen2021-03-101-3/+7
| | | | | | | | When jbig2_image_compose() errors out, remember to release all allocated pattern images. Previously the most recently allocated image would not be release. Finally remember to free the array of images itself.
* Searching for a marker in a stream, honor alignmentChris Liddell2020-11-271-3/+16
| | | | | | | | | | | | | | | | When searching for markers in a stream buffer, we were "seeking" to the point in the buffer, and casting to either a byte, ushort or a uint to make the value comparison. But we cannot do that on SPARC because of the strict alignment on that hardware. So, we have to "unpack" the individual bytes from the stream to do the value comparison. Note: there are slightly confusing comments in the code that mention being "on a 16 bit boundary" and "on a 32 bit boundary" - that's referring to the offset into the buffer, *not* the actual memory address alignment. Found in testing on Solaris/SPARC
* jbig2dec: Add casts to silence a compiler warning.Sebastian Rasmussen2020-11-071-2/+2
|
* Update jbig2dec stuff for 0.19 release.Sebastian Rasmussen2020-09-103-2/+21
|
* jbig2dec: Free result object upon error allocating referred to segments.Sebastian Rasmussen2020-06-231-0/+1
|
* jbig2dec: Fix memory leak caused by failing to allocate arithmetic coding ↵Sebastian Rasmussen2020-06-231-6/+8
| | | | context.
* lgtm.com issue: Add some missing "repeat include" guards.Robin Watts2020-05-081-5/+5
|
* Bug 702335: jbig2dec: Refill input buffer upon failure to parse segment header.Sebastian Rasmussen2020-04-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Before commit 2b2dcf4ccf401ed210f03c858b304994749fd2b3 there was a debug message when attempting to parse a a segment header and the data supplied to jbig2dec was not enough. Commit 2b2dcf4 incorrectly changed the debug message into a fatal error message, due misinterpreting the message text as something that warranted a fatal error. When data was supplied in chunks to jbig2_data_in() in repeated calls such that a segment header's referred-to segment numbers field straddled a chunk boundary then jbig2dec would indicate a fatal error. The file in bug 702335 caused this to happen. Instead jbig2dec should be asking the caller for more data so that the entire segment header can be parsed during a single call to jbig2_data_in(). By convering the fatal error back to a a debug message the problem is resolved. The message itself is also rewored to clearly indicate that the situation is non-fatal and that the caller will be asked to provide more data.
* Update copyright to 2020Chris Liddell2020-04-1039-39/+39
|
* jbig2dec: Initiate variable before avoids using uninited data during cleanup.Sebastian Rasmussen2020-04-051-3/+3
| | | | | | | Fixes OSS-fuzz issue 21571. Also fixes Coverity CID 355467. Thanks to OSS-fuzz for reporting.
* jbig2dec: Adjust number of bytes consumed by MMR decoder.Sebastian Rasmussen2020-04-031-11/+16
| | | | | | | | | | | | | | | | | | | | The MMR decoder pre-buffers up to 32 bits of encoded input data in a word buffer before they are consumed by the MMR decoder. Once bits are consumed, the pre-buffer will be filled up with more input data. When filling up the buffer the decoder would previously stay clear of reading data belonging to succeeding segments, but still indicated that it consumed those bytes it never read. Once finished the MMR decoder lied to the caller by propagating the incorrect number of consumed bytes. The caller subtracted the consumed number of bytes from the size and end up in underflow causing the next MMR decoding to first read input data at the wrong location, later ending up attempting to read outside the MMR encoded input buffer. Now, the MMR decoder keeps track of how many bits it has consumed and accurately rounds this number up to a whole number of bytes to the caller. Fixes OSS-fuzz issue 17855. Thanks to OSS-fuzz for reporting.
* jbig2dec: Plug leak of image upon error.Sebastian Rasmussen2020-04-021-15/+24
| | | | | | Fixes OSS-Fuzz issue 17513. Thanks to OSS-fuzz for reporting.
* jbig2dec: Need to store local copy of error message.Sebastian Rasmussen2020-04-021-17/+31
|
* jbig2dec: Cast literal to avoid shifting outside of valid range.Sebastian Rasmussen2020-03-211-1/+1
| | | | Fixes Coverity CID 355175.
* jbig2dec: Record stream errors in separate struct field.Sebastian Rasmussen2020-03-211-2/+6
| | | | | | | | | | Previously the number of remaining bytes in a read word (>= 0) and the error state (< 0) was stored in the same int field. Fixing signedness conversion warnings changed the type of the field to an unsigned field. The error state should have been stored separately at that time but it was overlooked. In this commit the error state is separated out into its own field. Fixes Coverity CID 355176.
* jbig2dec: Use correct define for maxium value of type.Sebastian Rasmussen2020-03-211-3/+3
| | | | Fixes Coverity CID 355177.
* jbig2dec: Fix two overlooked warnings.Sebastian Rasmussen2020-03-211-2/+2
| | | | | | | | | While working to fix all warnings seen when -Wsign-conversion is enabled, these two warnings were accidentally introduced by commit ff53af0d4ff9291aa5039522f5553a2850dd569d and not noticed in the avalanche of warnings emitted due to -Wsign-conversion. This commit changes the indicies to the type of the limit variable, fixing the warnings.
* jbig2dec: Fix signedness conversions.Sebastian Rasmussen2020-03-205-31/+55
|
* jbig2dec: Use uint32_t when counting segments.Sebastian Rasmussen2020-03-202-5/+12
|
* jbig2dec: Always use uint32_t when counting pages.Sebastian Rasmussen2020-03-203-5/+13
|
* jbig2dec: Handle errors from reading jbig2 streams.Sebastian Rasmussen2020-03-201-4/+21
|
* jbig2dec: Use size_t for string length.Sebastian Rasmussen2020-03-201-2/+1
|
* jbig2dec: Avoid formatting error messages twice in error callback.Sebastian Rasmussen2020-03-201-38/+29
|
* jbig2dec: Pass segment numbers as unsigned values to error callback.Sebastian Rasmussen2020-03-2015-125/+131
| | | | | | | | | | | | | According to the JBIG2 specification segments numbers are 32 bit unsigned integer. Previously any segment numbers larger than INT32_MAX would be passed as negative numbers. Some parts of the decoder do not yet know, or do not have access to the currently decoded segment number, and this needs to be specially indicated. Therefore jbig2dec appropriates the unlikely segment number 0xffffffff to indicate an unknown segment number. This is a change of the public API.
* Bug 701721: jbig2dec: Fix under/overflow handling in arithmetic integer decoder.Sebastian Rasmussen2020-03-201-2/+5
| | | | | | | | | | | | The previous detection logic caused GCC's -Wlogical-op to trip. Not only that, but the detection logic never took into account that underflow is not possible (the worst case is V == INT32_MIN, but offset is always > 0, so underflow cannot happen), nor take varying offset values into account (hardcoded limits meant that the offset was ignored even if it could not cause an overflow), but instead could cause non-clamped values to be emitted. This corrected logic adheres to the Annex A. Table A.1 in the specification.
* jbig2dec: Avoid warning by copying bytes instead of characters.Sebastian Rasmussen2020-03-201-4/+7
|
* jbig2dec: Enable warnings for signedness in comparisons.Sebastian Rasmussen2020-03-201-1/+1
|
* jbig2dec: Address all signedness comparison issues.Sebastian Rasmussen2020-03-208-24/+24
|
* jbig2dec: Remove trailing whitespace.Sebastian Rasmussen2020-03-204-10/+10
|
* jbig2dec: Avoid passing NULL buffer to snprintf().Sebastian Rasmussen2020-03-201-16/+13
|
* jbig2dec: Avoid artificially limiting jbig2dec.Sebastian Rasmussen2020-03-203-169/+0
| | | | | | | | | | | | | | | | | Commit 7366747076f3b75def52079bd4d5021539a16394 fixes bug 694949 by adding an artificial limit (that does not come from the JBIG2 specification) to the sizes of generic regions compared with the image they will be composed onto. A problem with such artificial limits is that they are arbitrary. This is exemplified by the changes in 0d21a58ab12b9584faa54baa48ce0dab350af53e to make jbig2dec not error out on commonly occurring images. It is impossible to know whether this updated limit is enough, or whether an even large generic region in a JBIG2 image will be found in the future. Instead of imposing these kinds of limits, jbig2dec should attempt to decode any JBIG2 image given to it. If the user wants to limit the amount of memory jbig2dec may use for decoding any JBIG2 image, this is a better way of implicitly limiting image sizes.
* Bug 702165: jbig2dec: Treat end of stream as fatal error, and remember errors.Sebastian Rasmussen2020-03-202-26/+54
| | | | | | | | * Treat reading beyond end of stream in arithmetic decoder as a fatal error. * Remember previously encountered stream errors in arithmetic decoder. * Ignore trailing bytes after terminating marker code in stream.
* jbig2dec: Add overflow detection for IAID context size.Sebastian Rasmussen2020-03-201-2/+11
|
* jbig2dec: Let arithmetic decoder and the underlying stream report errors.Sebastian Rasmussen2020-03-209-90/+121
| | | | | | When a called function indicates an error, the caller should print warnings. Since the arithmetic decoder now uses the normal way of reporting errors, the callers of the decoder are changed to report warnings.
* jbig2dec: Handle under-/overflow detection and messaging better.Sebastian Rasmussen2020-03-201-4/+14
| | | | | | | | | Previously SYMWIDTH was capped too early in order to prevent underflow Moreover TOTWIDTH was allowed to overflow. Now the value DW is checked compared to SYMWIDTH, preventing over underflow and overflow at the correct limits, and an overflow check has been added for TOTWIDTH.
* jbig2dec: Use unsigned suffix when defining UINT32_MAX.Sebastian Rasmussen2020-03-207-33/+10
| | | | | Also move UINT32_MAX/INT32_MAX to internal header so they are defined (the same) in every jbig2 source code file.
* jbig2dec: Keep type of index and array length the same.Sebastian Rasmussen2020-03-201-1/+1
|
* jbig2dec: Add more references to specification.Sebastian Rasmussen2020-03-203-3/+6
|
* jbig2dec: Add command line option to limit memory usage.Sebastian Rasmussen2020-03-201-7/+152
|
* jbig2dec: Mention all long options in usage and manpage.Sebastian Rasmussen2020-03-202-23/+28
|
* jbig2dec: Separate command line tool error callback state from parameters.Sebastian Rasmussen2020-03-201-33/+39
|
* Update jbig2dec stuff for 0.18 release.Sebastian Rasmussen2020-02-123-2/+9
|
* jbig2dec: Sync memento from ghostscript.Sebastian Rasmussen2020-02-121-0/+1
|