threads / discuss / 8734

error: wrong index file size in /usr/local/src/jffs2_mtd_patches/.git/objects/pack/pack-da39a3ee5e6b4b0d3255bfef95601890afd80709.idx

Subject: error: wrong index file size in /usr/local/src/jffs2_mtd_patches/.git/objects/pack/pack-da39a3ee5e6b4b0d3255bfef95601890afd80709.idx

## tl;dr

4 messages between Jun 26, 2007 and Jun 26, 2007.

replies: 3people: 3as markdown or json

Tjernlund· Jun 26, 2007, 20:03 UTC · lore
Did this and got a small error that I don't think should be there:
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git linux-2.6

cd linux-2.6 git gc cd ..

git clone --reference linux-2.6 ssh://git.infradead.org/~/public_git/jffs2_mtd_patches
Initialized empty Git repository in /usr/local/src/jffs2_mtd_patches/.git/
The authenticity of host 'git.infradead.org (18.85.46.34)' can't be established.
RSA key fingerprint is 45:df:f2:54:81:cf:42:05:1d:59:bb:dd:60:b5:0e:81.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'git.infradead.org' (RSA) to the list of known hosts.
remote: Generating pack...
remote: Done counting 0 objects.
Indexing 0 objects...
remote: Total 0 (delta 0), reused 0 (delta 0)
error: wrong index file size in /usr/local/src/jffs2_mtd_patches/.git/objects/pack/pack-da39a3ee5e6b4b0d3255bfef95601890afd80709.idx
Checking 21649 files out...
 100% (21649/21649) done

git --version git version 1.5.2.2

the ~ in above ssh: is jocke
Linus Torvalds· Jun 26, 2007, 20:45 UTC · re: Tjernlund · lore

Re: error: wrong index file size in /usr/local/src/jffs2_mtd_patches/.git/objects/pack/pack-da39a3ee5e6b4b0d32 55bfef95601890afd80709.idx

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);
 		}
Tjernlund· Jun 26, 2007, 21:14 UTC · re: Linus Torvalds · lore

RE: error: wrong index file size in /usr/local/src/jffs2_mtd_patches/.git/objects/pack/pack-da39a3ee5e6b4b0d32 55bfef95601890afd80709.idx

Show 28 quoted lines
> -----Original Message-----
> From: Linus Torvalds [mailto:torvalds@linux-foundation.org] 
> Sent: den 26 juni 2007 22:45
> To: Tjernlund
> Cc: git@vger.kernel.org
> Subject: Re: error: wrong index file size in 
> /usr/local/src/jffs2_mtd_patches/.git/objects/pack/pack-da39a3
> ee5e6b4b0d32 55bfef95601890afd80709.idx
> 
> 
> 
> 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-da39a3
ee5e6b4b0d3255bfef95601890afd80709.idx
Show 30 quoted lines
> 
> 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
[SNIP patch]
Tested your patch and the error went away, many thanks
 Jocke 
David Woodhouse· Jun 26, 2007, 20:55 UTC · re: Tjernlund · lore

Re: error: wrong index file size in /usr/local/src/jffs2_mtd_patches/.git/objects/pack/pack-da39a3ee5e6b4b0d3255bfef95601890afd80709.idx

On Tue, 2007-06-26 at 22:03 +0200, Tjernlund wrote:
Show 9 quoted lines
> Did this and got a small error that I don't think should be there:
> 
> git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git linux-2.6
> 
> cd linux-2.6
> git gc
> cd ..
> 
> git clone --reference linux-2.6 ssh://git.infradead.org/~/public_git/jffs2_mtd_patches

Your jffs2_mtd_patches tree is just a clone of git://git.infradead.org/mtd-2.6.git, isn't it?

I get the same error when cloning that:
pmac /home/dwmw2/x $ git-clone --reference /pmac/git/linux-2.6 git://git.infradead.org/mtd-2.6.git
Initialized empty Git repository in /home/dwmw2/x/mtd-2.6/.git/
remote: Generating pack...
remote: Done counting 0 objects.
remote: Total 0 (delta 0), reused 0 (delta 0)
Indexing 0 objects...
error: wrong index file size in /home/dwmw2/x/mtd-2.6/.git/objects/pack/pack-da39a3ee5e6b4b0d3255bfef95601890afd80709.idx
Checking 21649 files out...
 100% (21649/21649) done

The mtd-2.6.git tree has _no_ objects of its own at the moment; I've committed nothing since Linus' last pull, and there's a weekly 'git-repack -a -l -d', which will remove any local objects which are already in git://git.infradead.org/linux-2.6.git. Cloning linux-2.6.git from there works fine, but cloning mtd-2.6.git shows the above error.

-- 
dwmw2

← back to recent threads