summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 582c739)
raw | patch | inline | side by side (parent: 582c739)
author | Linus Torvalds <torvalds@linux-foundation.org> | |
Tue, 26 Jun 2007 21:34:02 +0000 (14:34 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 27 Jun 2007 01:02:15 +0000 (18:02 -0700) |
A pack-file can get created without any objects in it (to transfer "no
data" - which can happen if you use a reference git repo, for example,
or just otherwise just end up transferring only branch head information
and already have all the objects themselves).
And while we probably should never create an index for such a pack, if we
do (and we do), the index file size sanity checking was incorrect.
This fixes it.
Reported-and-tested-by: Jocke Tjernlund <tjernlund@tjernlund.se>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
data" - which can happen if you use a reference git repo, for example,
or just otherwise just end up transferring only branch head information
and already have all the objects themselves).
And while we probably should never create an index for such a pack, if we
do (and we do), the index file size sanity checking was incorrect.
This fixes it.
Reported-and-tested-by: Jocke Tjernlund <tjernlund@tjernlund.se>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1_file.c | patch | blob | history |
diff --git a/sha1_file.c b/sha1_file.c
index c2f807f4c282b99fe063e999ecf61a3dc12fb86d..b9d07de1564cb0ee8544cbc25428cdfd19a83ffd 100644 (file)
--- a/sha1_file.c
+++ b/sha1_file.c
* 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);
}