aboutsummaryrefslogtreecommitdiffstats
path: root/midx.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-11-18 18:23:53 +0900
committerJunio C Hamano <gitster@pobox.com>2018-11-18 18:23:53 +0900
commitab96f28ba4deb71ff64b31bd63cee96314db7112 (patch)
tree16ad5cafd201b65eb74c0c132f08b5ecc852fd92 /midx.c
parentfa2f2f085ed8999b799d48e652f9e438571e8491 (diff)
parent61b0fcbb64d00d52290d433c1e754c01740b3d19 (diff)
downloadgit-ab96f28ba4deb71ff64b31bd63cee96314db7112.tar.gz
Merge branch 'jk/unused-parameter-fixes'
Various functions have been audited for "-Wunused-parameter" warnings and bugs in them got fixed. * jk/unused-parameter-fixes: midx: double-check large object write loop assert NOARG/NONEG behavior of parse-options callbacks parse-options: drop OPT_DATE() apply: return -1 from option callback instead of calling exit(1) cat-file: report an error on multiple --batch options tag: mark "--message" option with NONEG show-branch: mark --reflog option as NONEG format-patch: mark "--no-numbered" option with NONEG status: mark --find-renames option with NONEG cat-file: mark batch options with NONEG pack-objects: mark index-version option as NONEG ls-files: mark exclude options as NONEG am: handle --no-patch-format option apply: mark include/exclude options as NONEG
Diffstat (limited to 'midx.c')
-rw-r--r--midx.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/midx.c b/midx.c
index a50b117b77..730ff84dff 100644
--- a/midx.c
+++ b/midx.c
@@ -721,12 +721,18 @@ static size_t write_midx_object_offsets(struct hashfile *f, int large_offset_nee
static size_t write_midx_large_offsets(struct hashfile *f, uint32_t nr_large_offset,
struct pack_midx_entry *objects, uint32_t nr_objects)
{
- struct pack_midx_entry *list = objects;
+ struct pack_midx_entry *list = objects, *end = objects + nr_objects;
size_t written = 0;
while (nr_large_offset) {
- struct pack_midx_entry *obj = list++;
- uint64_t offset = obj->offset;
+ struct pack_midx_entry *obj;
+ uint64_t offset;
+
+ if (list >= end)
+ BUG("too many large-offset objects");
+
+ obj = list++;
+ offset = obj->offset;
if (!(offset >> 31))
continue;