From 9e0f45f5a61d9d0556e6004198dd6a650be14bd9 Mon Sep 17 00:00:00 2001 From: Jonathan Tan Date: Fri, 18 Aug 2017 15:20:32 -0700 Subject: pack: move check_pack_index_ptr(), nth_packed_object_offset() Signed-off-by: Jonathan Tan Signed-off-by: Junio C Hamano --- packfile.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'packfile.h') diff --git a/packfile.h b/packfile.h index 790b174cb3..f4f5b936fc 100644 --- a/packfile.h +++ b/packfile.h @@ -63,6 +63,16 @@ extern void unuse_pack(struct pack_window **); extern void clear_delta_base_cache(void); extern struct packed_git *add_packed_git(const char *path, size_t path_len, int local); +/* + * Make sure that a pointer access into an mmap'd index file is within bounds, + * and can provide at least 8 bytes of data. + * + * Note that this is only necessary for variable-length segments of the file + * (like the 64-bit extended offset table), as we compare the size to the + * fixed-length parts when we open the file. + */ +extern void check_pack_index_ptr(const struct packed_git *p, const void *ptr); + /* * Return the SHA-1 of the nth object within the specified packfile. * Open the index if it is not already open. The return value points @@ -77,6 +87,11 @@ extern const unsigned char *nth_packed_object_sha1(struct packed_git *, uint32_t */ extern const struct object_id *nth_packed_object_oid(struct object_id *, struct packed_git *, uint32_t n); +/* + * Return the offset of the nth object within the specified packfile. + * The index must already be opened. + */ +extern off_t nth_packed_object_offset(const struct packed_git *, uint32_t n); extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsigned long *); extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep); @@ -94,4 +109,5 @@ extern int packed_object_info(struct packed_git *pack, off_t offset, struct obje extern void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1); extern const struct packed_git *has_packed_and_bad(const unsigned char *sha1); + #endif -- cgit 1.2.3-korg