All of lore.kernel.org
 help / color / mirror / Atom feed
* bug: SHA1 calculation on PPC machines when built with gcc older than 4.6
@ 2018-05-10 18:11 Ken Cunningham
  2018-05-10 18:30 ` Ævar Arnfjörð Bjarmason
  0 siblings, 1 reply; 2+ messages in thread
From: Ken Cunningham @ 2018-05-10 18:11 UTC (permalink / raw)
  To: git

Some vintage Apple PPC machines build a non-funtional version of git as of git 13.1 when using the stock gcc compilers that are installed with the OS; the SHA1 calculations are faulty. This can be repaired with a simple patch (attached).


Stock vintage Apple PPC machines come with gcc-4.0 or gcc-4.2. On MacOS 10.4 and earlier, or when not using Apple Common Crypto on 10.5, git uses the SHA1 calculation code from here <https://github.com/cr-marcstevens/sha1collisiondetection>. The code in <https://github.com/cr-marcstevens/sha1collisiondetection/blob/master/lib/sha1.c> tries to detect all systems that are BIG_ENDIAN, but the above noted systems fall through because they fail the tests.

It appears that the primary test:

#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)

only works as of gcc-4.6 and newer, so the code is built as LITTLE_ENDIAN on PPC with older gcc versions.


Issue report:

<https://github.com/cr-marcstevens/sha1collisiondetection/issues/40>


MacPorts bug report:

<https://trac.macports.org/ticket/54602>


The included patch to git fixes the issue on our testing.

Thanks for git!

Ken Cunningham




=====

diff --git a/sha1dc/sha1.c b/sha1dc/sha1.c
index 25eded1..5faf5a5 100644
--- a/sha1dc/sha1.c
+++ b/sha1dc/sha1.c
@@ -92,6 +92,10 @@
  */
 #define SHA1DC_BIGENDIAN
 
+#elif (defined(__APPLE__) && defined(__BIG_ENDIAN__) && !defined(SHA1DC_BIGENDIAN))
+/* older gcc compilers which are the default  on Apple PPC do not define __BYTE_ORDER__ */
+#define SHA1DC_BIGENDIAN
+
 /* Not under GCC-alike or glibc or *BSD or newlib or <processor whitelist> */
 #elif defined(SHA1DC_ON_INTEL_LIKE_PROCESSOR)
 /*

==========



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

* Re: bug: SHA1 calculation on PPC machines when built with gcc older than 4.6
  2018-05-10 18:11 bug: SHA1 calculation on PPC machines when built with gcc older than 4.6 Ken Cunningham
@ 2018-05-10 18:30 ` Ævar Arnfjörð Bjarmason
  0 siblings, 0 replies; 2+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2018-05-10 18:30 UTC (permalink / raw)
  To: Ken Cunningham; +Cc: Git Mailing List

On Thu, May 10, 2018 at 8:11 PM, Ken Cunningham
<ken.cunningham.webuse@gmail.com> wrote:
> Some vintage Apple PPC machines build a non-funtional version of git as of git 13.1 when using the stock gcc compilers that are installed with the OS; the SHA1 calculations are faulty. This can be repaired with a simple patch (attached).
>
>
> Stock vintage Apple PPC machines come with gcc-4.0 or gcc-4.2. On MacOS 10.4 and earlier, or when not using Apple Common Crypto on 10.5, git uses the SHA1 calculation code from here <https://github.com/cr-marcstevens/sha1collisiondetection>. The code in <https://github.com/cr-marcstevens/sha1collisiondetection/blob/master/lib/sha1.c> tries to detect all systems that are BIG_ENDIAN, but the above noted systems fall through because they fail the tests.
>
> It appears that the primary test:
>
> #if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)
>
> only works as of gcc-4.6 and newer, so the code is built as LITTLE_ENDIAN on PPC with older gcc versions.
>
>
> Issue report:
>
> <https://github.com/cr-marcstevens/sha1collisiondetection/issues/40>
>
>
> MacPorts bug report:
>
> <https://trac.macports.org/ticket/54602>
>
>
> The included patch to git fixes the issue on our testing.
>
> Thanks for git!
>
> Ken Cunningham
>
>
>
>
> =====
>
> diff --git a/sha1dc/sha1.c b/sha1dc/sha1.c
> index 25eded1..5faf5a5 100644
> --- a/sha1dc/sha1.c
> +++ b/sha1dc/sha1.c
> @@ -92,6 +92,10 @@
>   */
>  #define SHA1DC_BIGENDIAN
>
> +#elif (defined(__APPLE__) && defined(__BIG_ENDIAN__) && !defined(SHA1DC_BIGENDIAN))
> +/* older gcc compilers which are the default  on Apple PPC do not define __BYTE_ORDER__ */
> +#define SHA1DC_BIGENDIAN
> +
>  /* Not under GCC-alike or glibc or *BSD or newlib or <processor whitelist> */
>  #elif defined(SHA1DC_ON_INTEL_LIKE_PROCESSOR)
>  /*

Thanks. As noted in
https://public-inbox.org/git/87603xxc3k.fsf@evledraar.gmail.com/
patches like this should be sent to the upstream, it appears you just
opened an issue there, but sent the patch here. Could you open a PR
with upstream with this patch?

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

end of thread, other threads:[~2018-05-10 18:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-10 18:11 bug: SHA1 calculation on PPC machines when built with gcc older than 4.6 Ken Cunningham
2018-05-10 18:30 ` Ævar Arnfjörð Bjarmason

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.