notmuch sha1 implementation broken on (some) big-endian architectures

Subject: notmuch sha1 implementation broken on (some) big-endian architectures

Date: Sun, 24 Nov 2013 07:57:22 -0400

To: notmuch@notmuchmail.org

Cc:

From: David Bremner


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 <stdio.h>

#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;
}

Thread: