aboutsummaryrefslogtreecommitdiffstats
path: root/packfile.h
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2017-08-18 15:20:32 -0700
committerJunio C Hamano <gitster@pobox.com>2017-08-23 15:12:07 -0700
commit9e0f45f5a61d9d0556e6004198dd6a650be14bd9 (patch)
treef5037d6faeb9de15103198bd2801ecfa6946c5de /packfile.h
parentd5a16761820f2539bf8610c8f0c64f610e29314e (diff)
downloadgit-9e0f45f5a61d9d0556e6004198dd6a650be14bd9.tar.gz
pack: move check_pack_index_ptr(), nth_packed_object_offset()
Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'packfile.h')
-rw-r--r--packfile.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/packfile.h b/packfile.h
index 790b174cb3..f4f5b936fc 100644
--- a/packfile.h
+++ b/packfile.h
@@ -64,6 +64,16 @@ 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
* at the SHA-1 within the mmapped index. Return NULL if there is an
@@ -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