summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 03d6601)
raw | patch | inline | side by side (parent: 03d6601)
author | Nicolas Pitre <nico@cam.org> | |
Wed, 29 Oct 2008 23:02:49 +0000 (19:02 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 2 Nov 2008 23:22:35 +0000 (15:22 -0800) |
It currently calls die() whenever given offset is not found thinking
that such thing should never happen. But this offset may come from a
corrupted pack whych _could_ happen and not be found. Callers should
deal with this possibility gracefully instead.
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
that such thing should never happen. But this offset may come from a
corrupted pack whych _could_ happen and not be found. Callers should
deal with this possibility gracefully instead.
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-pack-objects.c | patch | blob | history | |
pack-revindex.c | patch | blob | history | |
sha1_file.c | patch | blob | history |
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index c05fb944b0e5d4d26cb2ba1995a787f08d5228ad..04a5a55ef94d411c99287e9c9ac5c75f73051e16 100644 (file)
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
if (reuse_delta && !entry->preferred_base) {
struct revindex_entry *revidx;
revidx = find_pack_revindex(p, ofs);
+ if (!revidx)
+ goto give_up;
base_ref = nth_packed_object_sha1(p, revidx->nr);
}
entry->in_pack_header_size = used + used_0;
diff --git a/pack-revindex.c b/pack-revindex.c
index 6096b6224ad551086afa346617eb714c15a51f78..1de53c8934c03b46604e94cbf4237ad5ffc57f83 100644 (file)
--- a/pack-revindex.c
+++ b/pack-revindex.c
else
lo = mi + 1;
} while (lo < hi);
- die("internal error: pack revindex corrupt");
+ error("bad offset for revindex");
+ return NULL;
}
void discard_revindex(void)
diff --git a/sha1_file.c b/sha1_file.c
index 384a43044e789612446cf1c6cb31fdf0dd037105..9ce1df0cff4aeaf5f2c3877980afe3fea99e7344 100644 (file)
--- a/sha1_file.c
+++ b/sha1_file.c
return OBJ_BAD;
type = packed_object_info(p, base_offset, NULL);
if (type <= OBJ_NONE) {
- struct revindex_entry *revidx = find_pack_revindex(p, base_offset);
- const unsigned char *base_sha1 =
- nth_packed_object_sha1(p, revidx->nr);
+ struct revindex_entry *revidx;
+ const unsigned char *base_sha1;
+ revidx = find_pack_revindex(p, base_offset);
+ if (!revidx)
+ return OBJ_BAD;
+ base_sha1 = nth_packed_object_sha1(p, revidx->nr);
mark_bad_packed_object(p, base_sha1);
type = sha1_object_info(base_sha1, NULL);
if (type <= OBJ_NONE)
* This is costly but should happen only in the presence
* of a corrupted pack, and is better than failing outright.
*/
- struct revindex_entry *revidx = find_pack_revindex(p, base_offset);
- const unsigned char *base_sha1 =
- nth_packed_object_sha1(p, revidx->nr);
+ struct revindex_entry *revidx;
+ const unsigned char *base_sha1;
+ revidx = find_pack_revindex(p, base_offset);
+ if (!revidx)
+ return NULL;
+ base_sha1 = nth_packed_object_sha1(p, revidx->nr);
error("failed to read delta base object %s"
" at offset %"PRIuMAX" from %s",
sha1_to_hex(base_sha1), (uintmax_t)base_offset,