From: Junio C Hamano <gitster@pobox.com>
To: Marc Stevens <marc@marc-stevens.nl>
Cc: "Michael Kebe" <michael.kebe@gmail.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Jeff King" <peff@peff.net>,
"Git Mailing List" <git@vger.kernel.org>
Subject: [PATCH] sha1dc: fix issues with a big endian platform
Date: Wed, 17 May 2017 14:39:57 +0900 [thread overview]
Message-ID: <xmqq37c4xcr6.fsf_-_@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <CAKKM46sS_5bVe5a6wNN7SdVoGvwmVxnLAZTxJ+tSftXfZKeGWg@mail.gmail.com> (Michael Kebe's message of "Tue, 16 May 2017 07:43:17 +0200")
From: Marc Stevens <marc@marc-stevens.nl>
Some big-endian platforms define _BIG_ENDIAN, which the test at the
beginning of file has missed. Also, when the input is not aligned,
some platforms trigger SIGBUS.
This change corresponds to 33a694a9 ("Fix issues with a big endian
platform", 2017-05-15) in the history of the upstream repository
https://github.com/cr-marcstevens/sha1collisiondetection
---
* So here is my attempt to clarify the log message (I left the
title as-is, but this change deals both with endianness and
alignment requirement).
Please look it over, and then sign-off your patch ;-)
Thanks.
P.S. I wonder how often "buf" is not aligned---could we somehow
optimize out memcpy when it is not necessary, or is it not worth
it?
sha1dc/sha1.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/sha1dc/sha1.c b/sha1dc/sha1.c
index 35e9dd5bf4..ae25318c47 100644
--- a/sha1dc/sha1.c
+++ b/sha1dc/sha1.c
@@ -20,7 +20,7 @@
*/
#if (defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) || \
(defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __BIG_ENDIAN__)) || \
- defined(__BIG_ENDIAN__) || defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \
+ defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN__) || defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \
defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__)
#define SHA1DC_BIGENDIAN 1
@@ -1728,7 +1728,8 @@ void SHA1DCUpdate(SHA1_CTX* ctx, const char* buf, size_t len)
while (len >= 64)
{
ctx->total += 64;
- sha1_process(ctx, (uint32_t*)(buf));
+ memcpy(ctx->buffer, buf, 64);
+ sha1_process(ctx, (uint32_t*)(ctx->buffer));
buf += 64;
len -= 64;
}
--
2.13.0-416-g4c6b804423
next prev parent reply other threads:[~2017-05-17 5:40 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-15 12:49 Git 2.13.0 segfaults on Solaris SPARC due to DC_SHA1=YesPlease being on by default Ævar Arnfjörð Bjarmason
2017-05-15 13:58 ` Marc Stevens
2017-05-15 14:13 ` Ævar Arnfjörð Bjarmason
2017-05-15 22:09 ` Jeff King
2017-06-01 14:03 ` demerphq
[not found] ` <CAKKM46vwM9pxyMxTc4jA0z_8vGKdDGCGg9ziKkFAsqr5ULYJxA@mail.gmail.com>
[not found] ` <007001d2cd88$2b916180$82b42480$@marc-stevens.nl>
2017-05-16 5:43 ` Michael Kebe
2017-05-17 5:39 ` Junio C Hamano [this message]
2017-05-17 6:30 ` [PATCH] sha1dc: fix issues with a big endian platform Ævar Arnfjörð Bjarmason
2017-05-17 7:09 ` Junio C Hamano
2017-05-17 11:38 ` [PATCH/RFC 0/3] Use sha1collisiondetection as a submodule Ævar Arnfjörð Bjarmason
2017-05-17 18:52 ` Stefan Beller
2017-05-17 19:45 ` Ævar Arnfjörð Bjarmason
2017-05-17 19:57 ` Stefan Beller
2017-05-18 0:11 ` Brandon Williams
2017-05-17 11:38 ` [PATCH/RFC 1/3] sha1dc: update from my fork of upstream Ævar Arnfjörð Bjarmason
2017-05-17 11:38 ` [PATCH/RFC 2/3] sha1dc: use sha1collisiondetection as a submodule Ævar Arnfjörð Bjarmason
2017-05-17 15:26 ` [PATCH] sha1dc: fix issues with a big endian platform Johannes Schindelin
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq37c4xcr6.fsf_-_@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=marc@marc-stevens.nl \
--cc=michael.kebe@gmail.com \
--cc=peff@peff.net \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).