{"thread":{"id":"48457","subject":"bug: SHA1 calculation on PPC machines when built with gcc older than 4.6","startedAt":"2018-05-10T18:11:51Z","lastAt":"2018-05-10T18:31:16Z","messageCount":2,"participants":["Ken Cunningham","Ævar Arnfjörð Bjarmason"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"347279","messageId":"418E3D80-FE0F-436B-B9D1-475E49C4D75D@gmail.com","threadId":"48457","inReplyTo":null,"subject":"bug: SHA1 calculation on PPC machines when built with gcc older than 4.6","fromName":"Ken Cunningham","fromEmail":"ken.cunningham.webuse@gmail.com","sentAt":"2018-05-10T18:11:44Z","receivedAt":"2018-05-10T18:11:51Z","isPatch":false,"sender":{"key":"ken.cunningham.webuse@gmail.com","avatar":null},"body":"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).\n\n\nStock 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.\n\nIt appears that the primary test:\n\n#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)\n\nonly works as of gcc-4.6 and newer, so the code is built as LITTLE_ENDIAN on PPC with older gcc versions.\n\n\nIssue report:\n\n<https://github.com/cr-marcstevens/sha1collisiondetection/issues/40>\n\n\nMacPorts bug report:\n\n<https://trac.macports.org/ticket/54602>\n\n\nThe included patch to git fixes the issue on our testing.\n\nThanks for git!\n\nKen Cunningham\n\n\n\n\n=====\n\ndiff --git a/sha1dc/sha1.c b/sha1dc/sha1.c\nindex 25eded1..5faf5a5 100644\n--- a/sha1dc/sha1.c\n+++ b/sha1dc/sha1.c\n@@ -92,6 +92,10 @@\n  */\n #define SHA1DC_BIGENDIAN\n \n+#elif (defined(__APPLE__) && defined(__BIG_ENDIAN__) && !defined(SHA1DC_BIGENDIAN))\n+/* older gcc compilers which are the default  on Apple PPC do not define __BYTE_ORDER__ */\n+#define SHA1DC_BIGENDIAN\n+\n /* Not under GCC-alike or glibc or *BSD or newlib or <processor whitelist> */\n #elif defined(SHA1DC_ON_INTEL_LIKE_PROCESSOR)\n /*\n\n==========\n\n\n"},{"id":"347285","messageId":"CACBZZX7Mgsd8cSzZc0YTPgziB6FiFhPiHZ_mG5C_PCshrp4=vg@mail.gmail.com","threadId":"48457","inReplyTo":"418E3D80-FE0F-436B-B9D1-475E49C4D75D@gmail.com","subject":"Re: bug: SHA1 calculation on PPC machines when built with gcc older than 4.6","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-05-10T18:30:52Z","receivedAt":"2018-05-10T18:31:16Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Thu, May 10, 2018 at 8:11 PM, Ken Cunningham\n<ken.cunningham.webuse@gmail.com> wrote:\n> 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).\n>\n>\n> 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.\n>\n> It appears that the primary test:\n>\n> #if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)\n>\n> only works as of gcc-4.6 and newer, so the code is built as LITTLE_ENDIAN on PPC with older gcc versions.\n>\n>\n> Issue report:\n>\n> <https://github.com/cr-marcstevens/sha1collisiondetection/issues/40>\n>\n>\n> MacPorts bug report:\n>\n> <https://trac.macports.org/ticket/54602>\n>\n>\n> The included patch to git fixes the issue on our testing.\n>\n> Thanks for git!\n>\n> Ken Cunningham\n>\n>\n>\n>\n> =====\n>\n> diff --git a/sha1dc/sha1.c b/sha1dc/sha1.c\n> index 25eded1..5faf5a5 100644\n> --- a/sha1dc/sha1.c\n> +++ b/sha1dc/sha1.c\n> @@ -92,6 +92,10 @@\n>   */\n>  #define SHA1DC_BIGENDIAN\n>\n> +#elif (defined(__APPLE__) && defined(__BIG_ENDIAN__) && !defined(SHA1DC_BIGENDIAN))\n> +/* older gcc compilers which are the default  on Apple PPC do not define __BYTE_ORDER__ */\n> +#define SHA1DC_BIGENDIAN\n> +\n>  /* Not under GCC-alike or glibc or *BSD or newlib or <processor whitelist> */\n>  #elif defined(SHA1DC_ON_INTEL_LIKE_PROCESSOR)\n>  /*\n\nThanks. As noted in\nhttps://public-inbox.org/git/87603xxc3k.fsf@evledraar.gmail.com/\npatches like this should be sent to the upstream, it appears you just\nopened an issue there, but sent the patch here. Could you open a PR\nwith upstream with this patch?\n"}]}