summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--index-pack.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/index-pack.c b/index-pack.c
index 530d820..c45ae20 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -365,8 +365,11 @@ static void *get_data_from_pack(struct object_entry *obj)
data = src;
do {
ssize_t n = pread(pack_fd, data + rdy, len - rdy, from + rdy);
- if (n <= 0)
+ if (n < 0)
die("cannot pread pack file: %s", strerror(errno));
+ if (!n)
+ die("premature end of pack file, %lu bytes missing",
+ len - rdy);
rdy += n;
} while (rdy < len);
data = xmalloc(obj->size);