MCPcopy Index your code
hub / github.com/git/git / unpack_object_header_buffer

Function unpack_object_header_buffer

packfile.c:1137–1164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1135}
1136
1137unsigned long unpack_object_header_buffer(const unsigned char *buf,
1138 unsigned long len, enum object_type *type, size_t *sizep)
1139{
1140 unsigned shift;
1141 size_t size, c;
1142 unsigned long used = 0;
1143
1144 c = buf[used++];
1145 *type = (c >> 4) & 7;
1146 size = c & 15;
1147 shift = 4;
1148 while (c & 0x80) {
1149 /*
1150 * Each continuation byte adds 7 bits. Ensure shift won't
1151 * overflow size_t (use size_t not long for 64-bit on Windows).
1152 */
1153 if (len <= used || (bitsizeof(size_t) - 7) < shift) {
1154 error("bad object header");
1155 size = used = 0;
1156 break;
1157 }
1158 c = buf[used++];
1159 size = st_add(size, st_left_shift(c & 0x7f, shift));
1160 shift += 7;
1161 }
1162 *sizep = size;
1163 return used;
1164}
1165
1166/*
1167 * Read a delta object's header at curpos in p (already inflated as needed)

Callers 4

unpack_object_headerFunction · 0.85
LLVMFuzzerTestOneInputFunction · 0.85
check_objectFunction · 0.85
oe_get_size_slowFunction · 0.85

Calls 3

errorFunction · 0.85
st_addFunction · 0.85
st_left_shiftFunction · 0.85

Tested by

no test coverage detected