MCPcopy Create free account
hub / github.com/git/git / check_pack_inflate

Function check_pack_inflate

builtin/pack-objects.c:457–481  ·  view source on GitHub ↗

* we are going to reuse the existing object data as is. make * sure it is not corrupt. */

Source from the content-addressed store, hash-verified

455 * sure it is not corrupt.
456 */
457static int check_pack_inflate(struct packed_git *p,
458 struct pack_window **w_curs,
459 off_t offset,
460 off_t len,
461 size_t expect)
462{
463 git_zstream stream;
464 unsigned char fakebuf[4096], *in;
465 int st;
466
467 memset(&stream, 0, sizeof(stream));
468 git_inflate_init(&stream);
469 do {
470 in = use_pack(p, w_curs, offset, &stream.avail_in);
471 stream.next_in = in;
472 stream.next_out = fakebuf;
473 stream.avail_out = sizeof(fakebuf);
474 st = git_inflate(&stream, Z_FINISH);
475 offset += stream.next_in - in;
476 } while (st == Z_OK || st == Z_BUF_ERROR);
477 git_inflate_end(&stream);
478 return (st == Z_STREAM_END &&
479 stream.total_out == expect &&
480 stream.total_in == len) ? 0 : -1;
481}
482
483static void copy_pack_data(struct hashfile *f,
484 struct packed_git *p,

Callers 1

write_reuse_objectFunction · 0.85

Calls 4

git_inflate_initFunction · 0.85
use_packFunction · 0.85
git_inflateFunction · 0.85
git_inflate_endFunction · 0.85

Tested by

no test coverage detected