| 2031 | MZ_MACRO_END |
| 2032 | |
| 2033 | tinfl_status tinfl_decompress(tinfl_decompressor *r, |
| 2034 | const mz_uint8 *pIn_buf_next, |
| 2035 | size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, |
| 2036 | mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, |
| 2037 | const mz_uint32 decomp_flags) { |
| 2038 | static const int s_length_base[31] = { |
| 2039 | 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, |
| 2040 | 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; |
| 2041 | static const int s_length_extra[31] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, |
| 2042 | 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, |
| 2043 | 4, 4, 5, 5, 5, 5, 0, 0, 0}; |
| 2044 | static const int s_dist_base[32] = { |
| 2045 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, |
| 2046 | 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, |
| 2047 | 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0}; |
| 2048 | static const int s_dist_extra[32] = {0, 0, 0, 0, 1, 1, 2, 2, 3, 3, |
| 2049 | 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, |
| 2050 | 9, 9, 10, 10, 11, 11, 12, 12, 13, 13}; |
| 2051 | static const mz_uint8 s_length_dezigzag[19] = { |
| 2052 | 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; |
| 2053 | static const int s_min_table_sizes[3] = {257, 1, 4}; |
| 2054 | |
| 2055 | tinfl_status status = TINFL_STATUS_FAILED; |
| 2056 | mz_uint32 num_bits, dist, counter, num_extra; |
| 2057 | tinfl_bit_buf_t bit_buf; |
| 2058 | const mz_uint8 *pIn_buf_cur = pIn_buf_next, |
| 2059 | *const pIn_buf_end = pIn_buf_next + *pIn_buf_size; |
| 2060 | mz_uint8 *pOut_buf_cur = pOut_buf_next, |
| 2061 | *const pOut_buf_end = pOut_buf_next + *pOut_buf_size; |
| 2062 | size_t out_buf_size_mask = |
| 2063 | (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF) |
| 2064 | ? (size_t)-1 |
| 2065 | : ((pOut_buf_next - pOut_buf_start) + *pOut_buf_size) - 1, |
| 2066 | dist_from_out_buf_start; |
| 2067 | |
| 2068 | // Ensure the output buffer's size is a power of 2, unless the output buffer |
| 2069 | // is large enough to hold the entire output file (in which case it doesn't |
| 2070 | // matter). |
| 2071 | if (((out_buf_size_mask + 1) & out_buf_size_mask) || |
| 2072 | (pOut_buf_next < pOut_buf_start)) { |
| 2073 | *pIn_buf_size = *pOut_buf_size = 0; |
| 2074 | return TINFL_STATUS_BAD_PARAM; |
| 2075 | } |
| 2076 | |
| 2077 | num_bits = r->m_num_bits; |
| 2078 | bit_buf = r->m_bit_buf; |
| 2079 | dist = r->m_dist; |
| 2080 | counter = r->m_counter; |
| 2081 | num_extra = r->m_num_extra; |
| 2082 | dist_from_out_buf_start = r->m_dist_from_out_buf_start; |
| 2083 | TINFL_CR_BEGIN |
| 2084 | |
| 2085 | bit_buf = num_bits = dist = counter = num_extra = r->m_zhdr0 = r->m_zhdr1 = 0; |
| 2086 | r->m_z_adler32 = r->m_check_adler32 = 1; |
| 2087 | if (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) { |
| 2088 | TINFL_GET_BYTE(1, r->m_zhdr0); |
| 2089 | TINFL_GET_BYTE(2, r->m_zhdr1); |
| 2090 | counter = (((r->m_zhdr0 * 256 + r->m_zhdr1) % 31 != 0) || |
no outgoing calls
no test coverage detected