| 166 | } |
| 167 | |
| 168 | enum unpack_loose_header_result unpack_loose_header(git_zstream *stream, |
| 169 | unsigned char *map, |
| 170 | unsigned long mapsize, |
| 171 | void *buffer, |
| 172 | unsigned long bufsiz) |
| 173 | { |
| 174 | int status; |
| 175 | |
| 176 | /* Get the data stream */ |
| 177 | memset(stream, 0, sizeof(*stream)); |
| 178 | stream->next_in = map; |
| 179 | stream->avail_in = mapsize; |
| 180 | stream->next_out = buffer; |
| 181 | stream->avail_out = bufsiz; |
| 182 | |
| 183 | git_inflate_init(stream); |
| 184 | obj_read_unlock(); |
| 185 | status = git_inflate(stream, 0); |
| 186 | obj_read_lock(); |
| 187 | if (status != Z_OK && status != Z_STREAM_END) |
| 188 | return ULHR_BAD; |
| 189 | |
| 190 | /* |
| 191 | * Check if entire header is unpacked in the first iteration. |
| 192 | */ |
| 193 | if (memchr(buffer, '\0', stream->next_out - (unsigned char *)buffer)) |
| 194 | return ULHR_OK; |
| 195 | |
| 196 | /* |
| 197 | * We have a header longer than MAX_HEADER_LEN. |
| 198 | */ |
| 199 | return ULHR_TOO_LONG; |
| 200 | } |
| 201 | |
| 202 | void *unpack_loose_rest(git_zstream *stream, |
| 203 | void *buffer, unsigned long size, |
no test coverage detected