git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix git-pack-objects for 64-bit platforms
@ 2006-05-11 17:36 Dennis Stosberg
  2006-05-11 17:58 ` Linus Torvalds
  0 siblings, 1 reply; 10+ messages in thread
From: Dennis Stosberg @ 2006-05-11 17:36 UTC (permalink / raw)
  To: git

The offset of an object in the pack is recorded as a 4-byte integer
in the index file.  When reading the offset from the mmap'ed index
in prepare_pack_revindex(), the address is dereferenced as a long*.
This works fine as long as the long type is four bytes wide.  On
NetBSD/sparc64, however, a long is 8 bytes wide and so dereferencing
the offset produces garbage.

Signed-off-by: Dennis Stosberg <dennis@stosberg.net>

---

I am not sure whether an int cast or an int32_t cast is more
appropriate here.  An int is not guaranteed to be four bytes wide,
but I don't know of any modern platform where that's not the case.
On the other hand int32_t is not necessarily available before C99.

Any opinions?  I wonder why no one has hit this on x86_64...


 pack-objects.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

026b1b2cdd5332f59e15cd8611a49ead3094d08c
diff --git a/pack-objects.c b/pack-objects.c
index 523a1c7..29bda43 100644
--- a/pack-objects.c
+++ b/pack-objects.c
@@ -156,7 +156,7 @@ static void prepare_pack_revindex(struct
 
 	rix->revindex = xmalloc(sizeof(unsigned long) * (num_ent + 1));
 	for (i = 0; i < num_ent; i++) {
-		long hl = *((long *)(index + 24 * i));
+		long hl = *((int *)(index + 24 * i));
 		rix->revindex[i] = ntohl(hl);
 	}
 	/* This knows the pack format -- the 20-byte trailer
-- 
1.3.2.gbe65

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2006-05-20 16:50 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-11 17:36 [PATCH] Fix git-pack-objects for 64-bit platforms Dennis Stosberg
2006-05-11 17:58 ` Linus Torvalds
2006-05-11 18:52   ` Junio C Hamano
2006-05-11 19:10     ` Linus Torvalds
2006-05-11 19:27     ` Linus Torvalds
2006-05-13  5:58       ` Junio C Hamano
2006-05-14 20:56         ` Ben Clifford
2006-05-14 20:58           ` [PATCH] include header to define uint32_t, necessary on Mac OS X Ben Clifford
2006-05-20 14:41             ` Alex Riesen
2006-05-20 16:50               ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).