aboutsummaryrefslogtreecommitdiff
path: root/pngrutil.c
AgeCommit message (Collapse)Author
2024-01-23chore: Clean up the return statements and update example.c accordinglyCosmin Truta
2024-01-23chore: Add, relocate or rephrase debug statements, for better clarityCosmin Truta
2024-01-18Do not build unused Adler32 codeJohn Bowler
This removes the default build of an undocumented feature to disable Adler32 checksums on those systems where it was the default. The PR is motived by github #187 however it fixes a much more general problem (#187 is limited to an issue where libpng "crashes" on some manufacturer systems). The fix is based on a suggestion by @sgowdev who is the originator of the issue. When libpng disables the checking of Adler32 checksums it does so by an undocumented and therefore possibly unsupported call to a zlib function which does not exist in some versions of zlib. Fortunately libpng only does this if the caller of libpng explicitly asks for it to happen. Unfortunately the call to the undocumented function is still in the compiled and built libpng and this means that on some systems (as identified in #187) libpng can fail to load or maybe even crash. The libpng authors are currently unaware of any program or system that uses this feature and none has been identified by the contributors to In this fix an option is added to *enable* the code so that by default the code is *disabled* - this is a simple generalization of the suggestion by @sgowdev. BENEFITS: the problem is eliminated, users of the functionality, if any, are idenfified, the functionality can be implemented correctly in the future or it can be removed. Hardly anyone complains. COSTS: someone will complain that they have to enable an option in a libpng build to use a feature that never worked consistently in the first place. This patch has been tested both with the option enabled and with it disabled via pngusr.dfa. Tests, checks pass with cmake and configure, make distcheck passes on configure. Reported-by: Stephen Gowen <dev.sgowen@gmail.com> Signed-off-by: John Bowler <jbowler@acm.org> Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2022-11-20Turn large PNG chunks into benign errorsCosmin Truta
Import Chromium commit https://chromium.googlesource.com/chromium/src/+/e87a02987101e2dbe319a4aba6b52470f7624b4a Add the author to the list of libpng contributing authors. Portions from the original commit message follow: *** A recent change to libpng [1] (included in Chromium with the recent libpng update [2]) turns chunks that are bigger than PNG_USER_CHUNK_MALLOC_MAX into failures. Although this matches the intent of PNG_USER_CHUNK_MALLOC_MAX, it also causes images which used to be viewable in Chromium to fail. Changing to a benign error allows us to display these images once again. Though it means we do allow libpng to allocate more than PNG_USER_CHUNK_MALLOC_MAX, it matches the behavior prior to [2] (when we were using 1.6.22), and it does not regress crbug.com/117369 [1] https://github.com/glennrp/libpng/commit/347538efbdc21b8df684ebd92d37400b3ce85d55 [2] https://chromium.googlesource.com/chromium/src/+/f82653a473f8de5fc86d0f2ecc75f6237e61946b *** Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=827754 Co-authored-by: Leon Scroggins III <scroggo@google.com> Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2022-09-14Fix a last-minute bug in the checking of the EXIF byte-order headerCosmin Truta
The check should fail if the EXIF byte-order header doesn't start with a correct character, or if the two heading characters aren't identical. Rewrite the check to make the code logic easier to follow.
2022-09-14Fix handling incorrect hIST chunks of uneven sizeCosmin Truta
The hIST chunks, used for storing image histograms, contain arrays of 16-bit unsigned integers, and the chunk size is expected to be an even number. Raise a png_chunk_benign_error() if a hIST chunk fails to meet this expectation. Reported-by: Eugene Kliuchnikov <eustas@google.com>
2022-09-14Simplify the definition of png_isaligned and avoid compiler warningsCosmin Truta
The following pointer subtraction was unnecessary: ((const char*)(ptr)-(const char*)0) In order to avoid further warnings about casting a wide pointer type to a narrower integer type, we cast the pointer to the target integer type through (size_t). Also fix a comment and reformat the surrounding code.
2021-03-13Remove duplicate lineBen Bullock
2021-03-13Fix decode fail on image with invalid eXIf chunkQiang Zhou
2020-04-27Fix memory leak if eXIf has incorrect crcskal
Problem description: Imagine a bitstream with an eXIf data segment that has invalid CRC. If png_crc_finish() fails at line 2090, info_ptr->eXIf_buf is not freed (despite the free_me setting at line 2062) because png_free_data() is not called. png_read_info() is actually looping several time over the png_eXIf chunk, calling png_handle_eXIf() several time in a row without freeing the buffer. This patch fixes the problem by leaving info_ptr's content in a clean state in case of failure, as it is done at line 2084.
2018-08-18Remove top-level const from function-scope variablesCosmin Truta
As per the const correctness rules, top-level const-ness of data in automatic scopes does not propagate outside of these scopes (unlike const-ness at lower levels, such as pointers to const data). Previously, const was used liberally, but inconsistently across the libpng codebase. Using const wherever applicable is not incorrect. However, _consistent_ use of const is difficult to maintain in such conditions. In conclusion, we shall continue to use const only where doing so is strictly necessary: 1. If a function guarantees that it will not modify an argument passed by pointer, the corresponding function parameter should be a pointer-to-const (const T *). 2. Static data should not be modified, therefore it should be const. Reference: Google C++ Style Guide https://google.github.io/styleguide/cppguide.html#Use_of_const
2018-08-18Replace the remaining uses of PNG_CONST with constCosmin Truta
In v1.6.0, compiler support for const became a requirement. It should be used consistently. To maintain backwards compatibility, PNG_CONST is still maintained in deprecated form.
2018-07-28Remove the "last changed" version information from source commentsCosmin Truta
This information is maintained by the version control system.
2018-07-15Release libpng version 1.6.35Cosmin Truta
2018-06-17[libpng16] Fix the calculation of row_factor in png_check_chunk_lengthCosmin Truta
(Bug report by Thuan Pham, SourceForge issue #278)
2018-06-17[libpng16] Replace the remaining uses of png_size_t with size_tCosmin Truta
In v1.6.0, size_t became a required type. It should be used consistently. To maintain backwards compatibility, png_size_t is still maintained in deprecated form.
2018-01-07[libpng16] Fix potential problem with bKGD (Cosmin Truta)Glenn Randers-Pehrson
2017-11-03Misc. typosUnknown
Some are user facing. Some are in actual code. Most are in source comments. Also, please double check the changes in contrib/tools/pngfix.c
2017-10-31[libpng16] Undo recent pngrutil.c change that did not fix oss-fuzz issueGlenn Randers-Pehrson
2017-10-29[libpng16] Initialize trans_color.red, green, and blue == trans_color.grayGlenn Randers-Pehrson
in attempt to stop an oss-fuzz "use of ininitialized value" issue
2017-10-29[libpng16] Revert recent changes that did not help with oss-fuzz issuesGlenn Randers-Pehrson
2017-10-20[libpng16] Initialize tRNS read buffers in pngrutil.cGlenn Randers-Pehrson
2017-10-17[libpng16] Initialize entire palette array to zero in png_handle_PLTE().Glenn Randers-Pehrson
2017-09-28[libpng16] Imported from libpng-1.6.33.tarGlenn Randers-Pehrson
2017-09-23[libpng16] Fix Coverity defect regarding errmsg in pngrutil.cGlenn Randers-Pehrson
2017-09-22[libpng16] Removed more redundant tests (suggested by "irwir" in Github ↵Glenn Randers-Pehrson
issue #180).
2017-09-22[libpng16] Relocate new memset() call in pngrutil.c (irwir).Glenn Randers-Pehrson
2017-09-20[libpng16] Removed a redundant test (suggested by "irwir" in Github issue #180).Glenn Randers-Pehrson
2017-09-20[libpng16] Bump version to 1.6.33rc01Glenn Randers-Pehrson
2017-09-19[libpng16] Add a memset() in png_read_buffer()Glenn Randers-Pehrson
2017-09-19[libpng16] Fix some commentsGlenn Randers-Pehrson
2017-09-18[libpng16] zero out memory allocated by png_inflateGlenn Randers-Pehrson
2017-09-02[libpng16] Imported from libpng-1.6.33beta02.tarGlenn Randers-Pehrson
2017-08-31[libpng16] Compute a larger limit on IDAT because some applications write aGlenn Randers-Pehrson
deflate buffer for each row (Bug report by Andrew Church).
2017-08-29[libpng16] Fix "last changed" datesGlenn Randers-Pehrson
2017-08-25[libpng16] Bump version to 1.6.33beta01Glenn Randers-Pehrson
2017-08-24[libpng16] Imported from libpng-1.6.32.tarGlenn Randers-Pehrson
2017-08-07[libpng16] Free eXIf_buf when detecting bad byte-order specifier.Glenn Randers-Pehrson
2017-08-06Fix typo (1 should be 2) in png_handle_eXIfGlenn Randers-Pehrson
2017-08-06[libpng16] Check that the eXIf chunk has at least 2 bytes and beginsGlenn Randers-Pehrson
with "II" or "MM".
2017-08-06[libpng16] Test or 11 bytes instead of 14 after the iCCP keyword has been read.Glenn Randers-Pehrson
2017-08-06[libpng16] Relocate the iCCP length test to a point after reading the keywordGlenn Randers-Pehrson
2017-08-06[libpng16] Increase minimum zlib stream from 9 to 14 in png_handle_iCCP(),Glenn Randers-Pehrson
to account for the minimum 'deflate' stream.
2017-08-05[lbpng16] Attempt to fix a UMR in png_set_text_2() to fix OSS-fuzz issue.Glenn Randers-Pehrson
2017-08-05[libpng16] Initialize profile_header[] in png_handle_iCCP() to fix OSS-fuzz ↵Glenn Randers-Pehrson
issue.
2017-08-05[Libpng16] Relocated setting free_me for eXIf data, to stop an OSS-fuzz leak.Glenn Randers-Pehrson
2017-08-05[libpng16] Make png_check_chunk_length|name() parameters constGlenn Randers-Pehrson
2017-08-05[libpng16] Removed unused chunk_name parameter from png_check_chunk_length().Glenn Randers-Pehrson
2017-08-04[libpng16] Moved chunk-length check into a png_check_chunk_length() privateGlenn Randers-Pehrson
function (Suggested by Max Stepin).
2017-08-04[libpng16] Removed a left-over debugging "printf" statement from pngrutil.cGlenn Randers-Pehrson