| 683 | /*************************************************************************************************/ |
| 684 | |
| 685 | INT32 Zlib_decompress(VECTOR_8 *out, const VECTOR_8 *in) // returns error value |
| 686 | { |
| 687 | UINT32 CM,CINFO,FDICT; |
| 688 | if (in->size < 2) { |
| 689 | return 53; // error, size of zlib data too small |
| 690 | } |
| 691 | if ((in->data[0] * 256 + in->data[1]) % 31 != 0) { |
| 692 | // error: 256 * in->data[0] + in->data[1] must be a multiple of 31, the FCHECK value is |
| 693 | // supposed to be made that way |
| 694 | return 24; |
| 695 | } |
| 696 | CM = in->data[0] & 15; |
| 697 | CINFO = (in->data[0] >> 4) & 15; |
| 698 | FDICT = (in->data[1] >> 5) & 1; |
| 699 | // DBG("compression method %d and CINFO=%d FDICT=%d\n", CM, CINFO, FDICT); |
| 700 | if (CM != 8 || CINFO > 7){ |
| 701 | // DBG("Error 25 : compression method %d and CINFO=%d FDICT=%d\n", CM, CINFO, FDICT); |
| 702 | // error: only compression method 8: inflate with sliding window of 32k is supported by |
| 703 | // the PNG spec |
| 704 | |
| 705 | return 25; |
| 706 | } |
| 707 | if (FDICT != 0){ |
| 708 | // DBG("Error 26 : compression method %d and CINFO=%d FDICT=%d\n", CM, CINFO, FDICT); |
| 709 | // error: the specification of PNG says about the zlib stream: "The additional flags shall |
| 710 | // not specify a preset dictionary." |
| 711 | return 26; |
| 712 | } |
| 713 | Inflator_inflate(out, in, 2); |
| 714 | return Inflator_error; // note: adler32 checksum was skipped and ignored |
| 715 | } |
| 716 | |
| 717 | /*************************************************************************************************/ |
| 718 |
no test coverage detected