Re: [PATCH] sha1dc: fix issues with a big endian platform

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 17, 2017 at 7:39 AM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
> From: Marc Stevens <marc@xxxxxxxxxxxxxxx>
>
> 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

Then why not just update sha1dc from upstream instead of
cherry-picking one patch from them? My update-sha1dc change does this:
https://github.com/git/git/compare/master...avar:update-sha1dc

This follows the instructions Jeff detailed in 28dc98e343. I solved a
few merge conflicts, I think I got them right, but review of that
especially welcome.

Maybe you just meant this patch for maint, but if that's the case it's
not clear from your commit message or E-Mail.

> ---
>
>  * 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
>



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]