]> git.ipfire.org Git - thirdparty/git.git/blobdiff - index-pack.c
diff --quiet
[thirdparty/git.git] / index-pack.c
index c56458ebd57841d1fe8d0a2b1a1927d840295344..b405864be954941dedc4b0cc0c7f7aefcf65dd2d 100644 (file)
@@ -277,13 +277,19 @@ static void *get_data_from_pack(struct object_entry *obj)
 {
        unsigned long from = obj[0].offset + obj[0].hdr_size;
        unsigned long len = obj[1].offset - from;
+       unsigned long rdy = 0;
        unsigned char *src, *data;
        z_stream stream;
        int st;
 
        src = xmalloc(len);
-       if (pread(pack_fd, src, len, from) != len)
-               die("cannot pread pack file: %s", strerror(errno));
+       data = src;
+       do {
+               ssize_t n = pread(pack_fd, data + rdy, len - rdy, from + rdy);
+               if (n <= 0)
+                       die("cannot pread pack file: %s", strerror(errno));
+               rdy += n;
+       } while (rdy < len);
        data = xmalloc(obj->size);
        memset(&stream, 0, sizeof(stream));
        stream.next_out = data;
@@ -457,7 +463,8 @@ static void parse_pack_objects(unsigned char *sha1)
        /* If input_fd is a file, we should have reached its end now. */
        if (fstat(input_fd, &st))
                die("cannot fstat packfile: %s", strerror(errno));
-       if (S_ISREG(st.st_mode) && st.st_size != consumed_bytes)
+       if (S_ISREG(st.st_mode) &&
+                       lseek(input_fd, 0, SEEK_CUR) - input_len != st.st_size)
                die("pack has junk at the end");
 
        if (!nr_deltas)
@@ -746,7 +753,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
                  const char *keep_name, const char *keep_msg,
                  unsigned char *sha1)
 {
-       char *report = "pack";
+       const char *report = "pack";
        char name[PATH_MAX];
        int err;