From 014becc955bcb421217b34bfba59f7f96eaa6a97 Mon Sep 17 00:00:00 2001 From: david Date: Mon, 25 Nov 2013 17:29:42 +2000 Subject: [PATCH] [PATCH 1/2] lib: fix byte order test in libsha1.c --- e1/ffe48122dcd4336db671b165ad57734ac82c2a | 90 +++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 e1/ffe48122dcd4336db671b165ad57734ac82c2a diff --git a/e1/ffe48122dcd4336db671b165ad57734ac82c2a b/e1/ffe48122dcd4336db671b165ad57734ac82c2a new file mode 100644 index 000000000..a80635b7d --- /dev/null +++ b/e1/ffe48122dcd4336db671b165ad57734ac82c2a @@ -0,0 +1,90 @@ +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 41E65431E64 + for ; Sun, 24 Nov 2013 13:30:07 -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 KY+z0XJKcq96 for ; + Sun, 24 Nov 2013 13:30:01 -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 E236D431FAE + for ; Sun, 24 Nov 2013 13:30:01 -0800 (PST) +Received: from remotemail by yantan.tethera.net with local (Exim 4.80) + (envelope-from ) + id 1VkhFd-0000YU-6U; Sun, 24 Nov 2013 17:29:57 -0400 +Received: (nullmailer pid 24664 invoked by uid 1000); Sun, 24 Nov 2013 + 21:29:53 -0000 +From: david@tethera.net +To: notmuch@notmuchmail.org +Subject: [PATCH 1/2] lib: fix byte order test in libsha1.c +Date: Sun, 24 Nov 2013 17:29:42 -0400 +Message-Id: <1385328583-24602-1-git-send-email-david@tethera.net> +X-Mailer: git-send-email 1.8.4.2 +In-Reply-To: +References: +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 21:30:07 -0000 + +From: David Bremner + +Previously PLATFORM_BYTE_ORDER and IS_LITTLE_ENDIAN were not defined, +so the little endian code was always compiled in. + +This will have the effect that the "SHA1s" on big endian architectures +will change (i.e. become actual sha1s). So someone re-indexing their +database could conceivable lose tags on messages without a message-id +header. +--- + lib/libsha1.c | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +diff --git a/lib/libsha1.c b/lib/libsha1.c +index 5d16f6a..794854b 100644 +--- a/lib/libsha1.c ++++ b/lib/libsha1.c +@@ -49,11 +49,17 @@ extern "C" + + #define bswap_32(x) ((rotr32((x), 24) & 0x00ff00ff) | (rotr32((x), 8) & 0xff00ff00)) + +-#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN) +-#define bsw_32(p,n) \ +- { int _i = (n); while(_i--) ((uint32_t*)p)[_i] = bswap_32(((uint32_t*)p)[_i]); } ++#ifdef __BYTE_ORDER__ ++# if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) ++# define bsw_32(p,n) \ ++ { int _i = (n); while(_i--) ((uint32_t*)p)[_i] = bswap_32(((uint32_t*)p)[_i]); } ++# elif (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) ++# define bsw_32(p,n) ++# else ++# error "unknown byte order" ++# endif + #else +-#define bsw_32(p,n) ++# error "macro __BYTE_ORDER__ is not defined" + #endif + + #define SHA1_MASK (SHA1_BLOCK_SIZE - 1) +-- +1.8.4.2 + -- 2.26.2