{"thread":{"id":"8734","subject":"error: wrong index file size in /usr/local/src/jffs2_mtd_patches/.git/objects/pack/pack-da39a3ee5e6b4b0d3255bfef95601890afd80709.idx","startedAt":"2007-06-26T20:03:28Z","lastAt":"2007-06-26T21:14:47Z","messageCount":4,"participants":["Tjernlund","Linus Torvalds","David Woodhouse"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"45844","messageId":"001401c7b82d$106f30b0$0e67a8c0@Jocke","threadId":"8734","inReplyTo":null,"subject":"error: wrong index file size in /usr/local/src/jffs2_mtd_patches/.git/objects/pack/pack-da39a3ee5e6b4b0d3255bfef95601890afd80709.idx","fromName":"Tjernlund","fromEmail":"tjernlund@tjernlund.se","sentAt":"2007-06-26T20:03:28Z","receivedAt":"2007-06-26T20:03:28Z","isPatch":false,"sender":{"key":"tjernlund@tjernlund.se","avatar":null},"body":"Did this and got a small error that I don't think should be there:\n\ngit clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git linux-2.6\n\ncd linux-2.6\ngit gc\ncd ..\n\ngit clone --reference linux-2.6 ssh://git.infradead.org/~/public_git/jffs2_mtd_patches\nInitialized empty Git repository in /usr/local/src/jffs2_mtd_patches/.git/\nThe authenticity of host 'git.infradead.org (18.85.46.34)' can't be established.\nRSA key fingerprint is 45:df:f2:54:81:cf:42:05:1d:59:bb:dd:60:b5:0e:81.\nAre you sure you want to continue connecting (yes/no)? yes\nWarning: Permanently added 'git.infradead.org' (RSA) to the list of known hosts.\nremote: Generating pack...\nremote: Done counting 0 objects.\nIndexing 0 objects...\nremote: Total 0 (delta 0), reused 0 (delta 0)\nerror: wrong index file size in /usr/local/src/jffs2_mtd_patches/.git/objects/pack/pack-da39a3ee5e6b4b0d3255bfef95601890afd80709.idx\nChecking 21649 files out...\n 100% (21649/21649) done\n\ngit --version\ngit version 1.5.2.2\n\nthe ~ in above ssh: is jocke\n"},{"id":"45845","messageId":"alpine.LFD.0.98.0706261341190.8675@woody.linux-foundation.org","threadId":"8734","inReplyTo":"001401c7b82d$106f30b0$0e67a8c0@Jocke","subject":"Re: error: wrong index file size in /usr/local/src/jffs2_mtd_patches/.git/objects/pack/pack-da39a3ee5e6b4b0d32 55bfef95601890afd80709.idx","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2007-06-26T20:45:07Z","receivedAt":"2007-06-26T20:45:07Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Tue, 26 Jun 2007, Tjernlund wrote:\n>\n> Did this and got a small error that I don't think should be there:\n\nHeh. I think I see what's wrong..\n\n> Indexing 0 objects...\n> remote: Total 0 (delta 0), reused 0 (delta 0)\n\nOk, there were no objects that weren't in the reference repo. So far so \ngood.\n\nBut:\n\n> error: wrong index file size in /usr/local/src/jffs2_mtd_patches/.git/objects/pack/pack-da39a3ee5e6b4b0d3255bfef95601890afd80709.idx\n\nI think this is because of that zero size:\n\n                /*\n                 * Minimum size:\n                 *  - 8 bytes of header\n                 *  - 256 index entries 4 bytes each\n                 *  - 20-byte sha1 entry * nr\n                 *  - 4-byte crc entry * nr\n                 *  - 4-byte offset entry * nr\n                 *  - 20-byte SHA1 of the packfile\n                 *  - 20-byte SHA1 file checksum\n                 * And after the 4-byte offset table might be a\n                 * variable sized table containing 8-byte entries\n                 * for offsets larger than 2^31.\n                 */\n                unsigned long min_size = 8 + 4*256 + nr*(20 + 4 + 4) + 20 + 20;\n                if (idx_size < min_size || idx_size > min_size + (nr - 1)*8) {\n\nNotice the \"(nr - 1)*8\" thing. And notice how \"nr-1\" underflows when nr is \nzero..\n\nI bet it goes away if you remove the \"-1\", or if you do something like \nthis (totally untested!) patch.\n\n\t\tLinus\n\n---\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 7628ee9..f2b1ae0 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -510,7 +510,10 @@ static int check_packed_git_idx(const char *path,  struct packed_git *p)\n \t\t * for offsets larger than 2^31.\n \t\t */\n \t\tunsigned long min_size = 8 + 4*256 + nr*(20 + 4 + 4) + 20 + 20;\n-\t\tif (idx_size < min_size || idx_size > min_size + (nr - 1)*8) {\n+\t\tunsigned long max_size = min_size;\n+\t\tif (nr)\n+\t\t\tmax_size += (nr - 1)*8;\n+\t\tif (idx_size < min_size || idx_size > max_size) {\n \t\t\tmunmap(idx_map, idx_size);\n \t\t\treturn error(\"wrong index file size in %s\", path);\n \t\t}\n"},{"id":"45846","messageId":"1182891315.3263.47.camel@shinybook.infradead.org","threadId":"8734","inReplyTo":"001401c7b82d$106f30b0$0e67a8c0@Jocke","subject":"Re: error: wrong index file size in /usr/local/src/jffs2_mtd_patches/.git/objects/pack/pack-da39a3ee5e6b4b0d3255bfef95601890afd80709.idx","fromName":"David Woodhouse","fromEmail":"dwmw2@infradead.org","sentAt":"2007-06-26T20:55:15Z","receivedAt":"2007-06-26T20:55:15Z","isPatch":false,"sender":{"key":"dwmw2@infradead.org","avatar":"https://gravatar.com/avatar/7afd4f07e0cf7d7e046ae2d23678296b37777c96488e6f3451e78a5514154ebd?d=mp&s=160"},"body":"On Tue, 2007-06-26 at 22:03 +0200, Tjernlund wrote:\n> Did this and got a small error that I don't think should be there:\n> \n> git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git linux-2.6\n> \n> cd linux-2.6\n> git gc\n> cd ..\n> \n> git clone --reference linux-2.6 ssh://git.infradead.org/~/public_git/jffs2_mtd_patches\n\nYour jffs2_mtd_patches tree is just a clone of\ngit://git.infradead.org/mtd-2.6.git, isn't it?\n\nI get the same error when cloning that:\n\npmac /home/dwmw2/x $ git-clone --reference /pmac/git/linux-2.6 git://git.infradead.org/mtd-2.6.git\nInitialized empty Git repository in /home/dwmw2/x/mtd-2.6/.git/\nremote: Generating pack...\nremote: Done counting 0 objects.\nremote: Total 0 (delta 0), reused 0 (delta 0)\nIndexing 0 objects...\nerror: wrong index file size in /home/dwmw2/x/mtd-2.6/.git/objects/pack/pack-da39a3ee5e6b4b0d3255bfef95601890afd80709.idx\nChecking 21649 files out...\n 100% (21649/21649) done\n\nThe mtd-2.6.git tree has _no_ objects of its own at the moment; I've\ncommitted nothing since Linus' last pull, and there's a weekly\n'git-repack -a -l -d', which will remove any local objects which are\nalready in git://git.infradead.org/linux-2.6.git. Cloning linux-2.6.git\nfrom there works fine, but cloning mtd-2.6.git shows the above error.\n\n-- \ndwmw2\n"},{"id":"45848","messageId":"001601c7b837$067d1040$0e67a8c0@Jocke","threadId":"8734","inReplyTo":"alpine.LFD.0.98.0706261341190.8675@woody.linux-foundation.org","subject":"RE: error: wrong index file size in /usr/local/src/jffs2_mtd_patches/.git/objects/pack/pack-da39a3ee5e6b4b0d32 55bfef95601890afd80709.idx","fromName":"Tjernlund","fromEmail":"tjernlund@tjernlund.se","sentAt":"2007-06-26T21:14:47Z","receivedAt":"2007-06-26T21:14:47Z","isPatch":false,"sender":{"key":"tjernlund@tjernlund.se","avatar":null},"body":" \n\n> -----Original Message-----\n> From: Linus Torvalds [mailto:torvalds@linux-foundation.org] \n> Sent: den 26 juni 2007 22:45\n> To: Tjernlund\n> Cc: git@vger.kernel.org\n> Subject: Re: error: wrong index file size in \n> /usr/local/src/jffs2_mtd_patches/.git/objects/pack/pack-da39a3\n> ee5e6b4b0d32 55bfef95601890afd80709.idx\n> \n> \n> \n> On Tue, 26 Jun 2007, Tjernlund wrote:\n> >\n> > Did this and got a small error that I don't think should be there:\n> \n> Heh. I think I see what's wrong..\n> \n> > Indexing 0 objects...\n> > remote: Total 0 (delta 0), reused 0 (delta 0)\n> \n> Ok, there were no objects that weren't in the reference repo. \n> So far so \n> good.\n> \n> But:\n> \n> > error: wrong index file size in \n> /usr/local/src/jffs2_mtd_patches/.git/objects/pack/pack-da39a3\nee5e6b4b0d3255bfef95601890afd80709.idx\n> \n> I think this is because of that zero size:\n> \n>                 /*\n>                  * Minimum size:\n>                  *  - 8 bytes of header\n>                  *  - 256 index entries 4 bytes each\n>                  *  - 20-byte sha1 entry * nr\n>                  *  - 4-byte crc entry * nr\n>                  *  - 4-byte offset entry * nr\n>                  *  - 20-byte SHA1 of the packfile\n>                  *  - 20-byte SHA1 file checksum\n>                  * And after the 4-byte offset table might be a\n>                  * variable sized table containing 8-byte entries\n>                  * for offsets larger than 2^31.\n>                  */\n>                 unsigned long min_size = 8 + 4*256 + nr*(20 + \n> 4 + 4) + 20 + 20;\n>                 if (idx_size < min_size || idx_size > \n> min_size + (nr - 1)*8) {\n> \n> Notice the \"(nr - 1)*8\" thing. And notice how \"nr-1\" \n> underflows when nr is \n> zero..\n> \n> I bet it goes away if you remove the \"-1\", or if you do \n> something like \n> this (totally untested!) patch.\n> \n> \t\tLinus\n\n[SNIP patch]\n\nTested your patch and the error went away, many thanks\n\n Jocke \n"}]}