|
1 | 1 | /* |
2 | | -LodePNG version 20170917 |
| 2 | +LodePNG version 20180114 |
3 | 3 |
|
4 | | -Copyright (c) 2005-2017 Lode Vandevenne |
| 4 | +Copyright (c) 2005-2018 Lode Vandevenne |
5 | 5 |
|
6 | 6 | This software is provided 'as-is', without any express or implied |
7 | 7 | warranty. In no event will the authors be held liable for any damages |
@@ -39,7 +39,7 @@ Rename this file to lodepng.cpp to use it for C++, or to lodepng.c to use it for |
39 | 39 | #pragma warning( disable : 4996 ) /*VS does not like fopen, but fopen_s is not standard C so unusable here*/ |
40 | 40 | #endif /*_MSC_VER */ |
41 | 41 |
|
42 | | -const char* LODEPNG_VERSION_STRING = "20170917"; |
| 42 | +const char* LODEPNG_VERSION_STRING = "20180114"; |
43 | 43 |
|
44 | 44 | /* |
45 | 45 | This source file is built up in the following large parts. The code sections |
@@ -4565,12 +4565,20 @@ static void decodeGeneric(unsigned char** out, unsigned* w, unsigned* h, |
4565 | 4565 | const unsigned char* data; /*the data in the chunk*/ |
4566 | 4566 |
|
4567 | 4567 | /*error: size of the in buffer too small to contain next chunk*/ |
4568 | | - if((size_t)((chunk - in) + 12) > insize || chunk < in) CERROR_BREAK(state->error, 30); |
| 4568 | + if((size_t)((chunk - in) + 12) > insize || chunk < in) |
| 4569 | + { |
| 4570 | + if(state->decoder.ignore_end) break; /*other errors may still happen though*/ |
| 4571 | + CERROR_BREAK(state->error, 30); |
| 4572 | + } |
4569 | 4573 |
|
4570 | 4574 | /*length of the data of the chunk, excluding the length bytes, chunk type and CRC bytes*/ |
4571 | 4575 | chunkLength = lodepng_chunk_length(chunk); |
4572 | 4576 | /*error: chunk length larger than the max PNG chunk size*/ |
4573 | | - if(chunkLength > 2147483647) CERROR_BREAK(state->error, 63); |
| 4577 | + if(chunkLength > 2147483647) |
| 4578 | + { |
| 4579 | + if(state->decoder.ignore_end) break; /*other errors may still happen though*/ |
| 4580 | + CERROR_BREAK(state->error, 63); |
| 4581 | + } |
4574 | 4582 |
|
4575 | 4583 | if((size_t)((chunk - in) + chunkLength + 12) > insize || (chunk + chunkLength + 12) < in) |
4576 | 4584 | { |
@@ -4657,7 +4665,10 @@ static void decodeGeneric(unsigned char** out, unsigned* w, unsigned* h, |
4657 | 4665 | else /*it's not an implemented chunk type, so ignore it: skip over the data*/ |
4658 | 4666 | { |
4659 | 4667 | /*error: unknown critical chunk (5th bit of first byte of chunk type is 0)*/ |
4660 | | - if(!lodepng_chunk_ancillary(chunk)) CERROR_BREAK(state->error, 69); |
| 4668 | + if(!state->decoder.ignore_critical && !lodepng_chunk_ancillary(chunk)) |
| 4669 | + { |
| 4670 | + CERROR_BREAK(state->error, 69); |
| 4671 | + } |
4661 | 4672 |
|
4662 | 4673 | unknown = 1; |
4663 | 4674 | #ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS |
@@ -4822,6 +4833,8 @@ void lodepng_decoder_settings_init(LodePNGDecoderSettings* settings) |
4822 | 4833 | settings->remember_unknown_chunks = 0; |
4823 | 4834 | #endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/ |
4824 | 4835 | settings->ignore_crc = 0; |
| 4836 | + settings->ignore_critical = 0; |
| 4837 | + settings->ignore_end = 0; |
4825 | 4838 | lodepng_decompress_settings_init(&settings->zlibsettings); |
4826 | 4839 | } |
4827 | 4840 |
|
|
0 commit comments