git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Clarke <jrtc27@jrtc27.com>
To: gitster@pobox.com
Cc: James Clarke <jrtc27@jrtc27.com>, git@vger.kernel.org
Subject: [PATCH] pack-bitmap: Don't perform unaligned memory access
Date: Mon, 26 Jun 2017 16:16:12 +0100	[thread overview]
Message-ID: <20170626151612.64019-1-jrtc27@jrtc27.com> (raw)

The preceding bitmap entries have a 1-byte XOR-offset and 1-byte flags,
so their size is not a multiple of 4. Thus the name-hash cache is only
guaranteed to be 2-byte aligned and so we must use get_be32 rather than
indexing the array directly.

Signed-off-by: James Clarke <jrtc27@jrtc27.com>
---

This was noticed thanks to the recent tests added to t5310-pack-bitmaps.sh,
which were crashing with SIGBUS on Debian sparc64. All tests (excluding those
marked with known breakage) now pass again.

 pack-bitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pack-bitmap.c b/pack-bitmap.c
index a3ac3dccd..327634cd7 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -627,7 +627,7 @@ static void show_objects_for_type(
 			sha1 = nth_packed_object_sha1(bitmap_git.pack, entry->nr);

 			if (bitmap_git.hashes)
-				hash = ntohl(bitmap_git.hashes[entry->nr]);
+				hash = get_be32(bitmap_git.hashes + entry->nr);

 			show_reach(sha1, object_type, 0, hash, bitmap_git.pack, entry->offset);
 		}
--
2.13.2


             reply	other threads:[~2017-06-26 15:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-26 15:16 James Clarke [this message]
2017-06-26 19:30 ` [PATCH] pack-bitmap: Don't perform unaligned memory access Junio C Hamano
2017-06-27  0:06 ` Jonathan Nieder

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=20170626151612.64019-1-jrtc27@jrtc27.com \
    --to=jrtc27@jrtc27.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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;
as well as URLs for NNTP newsgroup(s).