| 28 | } |
| 29 | |
| 30 | int check_pack_crc(struct packed_git *p, struct pack_window **w_curs, |
| 31 | off_t offset, off_t len, unsigned int nr) |
| 32 | { |
| 33 | const uint32_t *index_crc; |
| 34 | uint32_t data_crc = crc32(0, NULL, 0); |
| 35 | |
| 36 | do { |
| 37 | unsigned long avail; |
| 38 | void *data = use_pack(p, w_curs, offset, &avail); |
| 39 | if (avail > len) |
| 40 | avail = len; |
| 41 | data_crc = crc32(data_crc, data, avail); |
| 42 | offset += avail; |
| 43 | len -= avail; |
| 44 | } while (len); |
| 45 | |
| 46 | index_crc = p->index_data; |
| 47 | index_crc += 2 + 256 + (size_t)p->num_objects * (p->repo->hash_algo->rawsz/4) + nr; |
| 48 | |
| 49 | return data_crc != ntohl(*index_crc); |
| 50 | } |
| 51 | |
| 52 | static int verify_packfile(struct repository *r, |
| 53 | struct packed_git *p, |
no test coverage detected