From: David Bremner Date: Sun, 24 Nov 2013 11:57:22 +0000 (+2000) Subject: notmuch sha1 implementation broken on (some) big-endian architectures X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=733ccbca5a131a952ac75d18810a591033ea37b8;p=notmuch-archives.git notmuch sha1 implementation broken on (some) big-endian architectures --- diff --git a/4e/cb5263f8ac915ebdca43bf9a405fb3c2530b2d b/4e/cb5263f8ac915ebdca43bf9a405fb3c2530b2d new file mode 100644 index 000000000..b29bcd164 --- /dev/null +++ b/4e/cb5263f8ac915ebdca43bf9a405fb3c2530b2d @@ -0,0 +1,76 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 30F07431FCB + for ; Sun, 24 Nov 2013 03:57:37 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id FuP5Bi1-hBGP for ; + Sun, 24 Nov 2013 03:57:32 -0800 (PST) +Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155]) + (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 74822431FC3 + for ; Sun, 24 Nov 2013 03:57:32 -0800 (PST) +Received: from remotemail by yantan.tethera.net with local (Exim 4.80) + (envelope-from ) + id 1VkYJb-0006q3-8T; Sun, 24 Nov 2013 07:57:27 -0400 +Received: (nullmailer pid 29436 invoked by uid 1000); Sun, 24 Nov 2013 + 11:57:23 -0000 +From: David Bremner +To: notmuch@notmuchmail.org +Subject: notmuch sha1 implementation broken on (some) big-endian architectures +User-Agent: Notmuch/0.17~rc1 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-pc-linux-gnu) +Date: Sun, 24 Nov 2013 07:57:22 -0400 +Message-ID: <87eh666mhp.fsf@zancas.localnet> +MIME-Version: 1.0 +Content-Type: text/plain +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sun, 24 Nov 2013 11:57:37 -0000 + + +The following code, when linked with libnotmuch.a and libutil.a does a +passable imitation of sha1sum on amd64 (and I guess also i386) but +computes a different digest on powerpc and probably sparc and s390x. + +In the long run we should maybe outsource hash computations to +e.g. librhash, but I'd like a simpler fix for 0.17, if possible + +P.S. I blame Austin for adding the "missing-headers" test which found +this bug ;). + +/* 8<----------------------------------------- */ + +#include + +#include "notmuch.h" +char * notmuch_sha1_of_file(const char* filename); + +int +main (int argc, char **argv) +{ + + char *digest = notmuch_sha1_of_file (argv[1]); + + printf("%s %s\n",digest,argv[1]); + return 0; +}