From: Linus Torvalds <torvalds@linux-foundation.org>
To: Tjernlund <tjernlund@tjernlund.se>
Cc: git@vger.kernel.org
Subject: Re: error: wrong index file size in /usr/local/src/jffs2_mtd_patches/.git/objects/pack/pack-da39a3ee5e6b4b0d32 55bfef95601890afd80709.idx
Date: Tue, 26 Jun 2007 13:45:07 -0700 (PDT) [thread overview]
Message-ID: <alpine.LFD.0.98.0706261341190.8675@woody.linux-foundation.org> (raw)
In-Reply-To: <001401c7b82d$106f30b0$0e67a8c0@Jocke>
On Tue, 26 Jun 2007, Tjernlund wrote:
>
> Did this and got a small error that I don't think should be there:
Heh. I think I see what's wrong..
> Indexing 0 objects...
> remote: Total 0 (delta 0), reused 0 (delta 0)
Ok, there were no objects that weren't in the reference repo. So far so
good.
But:
> error: wrong index file size in /usr/local/src/jffs2_mtd_patches/.git/objects/pack/pack-da39a3ee5e6b4b0d3255bfef95601890afd80709.idx
I think this is because of that zero size:
/*
* Minimum size:
* - 8 bytes of header
* - 256 index entries 4 bytes each
* - 20-byte sha1 entry * nr
* - 4-byte crc entry * nr
* - 4-byte offset entry * nr
* - 20-byte SHA1 of the packfile
* - 20-byte SHA1 file checksum
* And after the 4-byte offset table might be a
* variable sized table containing 8-byte entries
* for offsets larger than 2^31.
*/
unsigned long min_size = 8 + 4*256 + nr*(20 + 4 + 4) + 20 + 20;
if (idx_size < min_size || idx_size > min_size + (nr - 1)*8) {
Notice the "(nr - 1)*8" thing. And notice how "nr-1" underflows when nr is
zero..
I bet it goes away if you remove the "-1", or if you do something like
this (totally untested!) patch.
Linus
---
diff --git a/sha1_file.c b/sha1_file.c
index 7628ee9..f2b1ae0 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -510,7 +510,10 @@ static int check_packed_git_idx(const char *path, struct packed_git *p)
* for offsets larger than 2^31.
*/
unsigned long min_size = 8 + 4*256 + nr*(20 + 4 + 4) + 20 + 20;
- if (idx_size < min_size || idx_size > min_size + (nr - 1)*8) {
+ unsigned long max_size = min_size;
+ if (nr)
+ max_size += (nr - 1)*8;
+ if (idx_size < min_size || idx_size > max_size) {
munmap(idx_map, idx_size);
return error("wrong index file size in %s", path);
}
next prev parent reply other threads:[~2007-06-26 20:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-26 20:03 error: wrong index file size in /usr/local/src/jffs2_mtd_patches/.git/objects/pack/pack-da39a3ee5e6b4b0d3255bfef95601890afd80709.idx Tjernlund
2007-06-26 20:45 ` Linus Torvalds [this message]
2007-06-26 21:14 ` error: wrong index file size in /usr/local/src/jffs2_mtd_patches/.git/objects/pack/pack-da39a3ee5e6b4b0d32 55bfef95601890afd80709.idx Tjernlund
2007-06-26 20:55 ` error: wrong index file size in /usr/local/src/jffs2_mtd_patches/.git/objects/pack/pack-da39a3ee5e6b4b0d3255bfef95601890afd80709.idx David Woodhouse
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LFD.0.98.0706261341190.8675@woody.linux-foundation.org \
--to=torvalds@linux-foundation.org \
--cc=git@vger.kernel.org \
--cc=tjernlund@tjernlund.se \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox