[dovecot-cvs] dovecot/src/lib printf-upper-bound.c, 1.4, 1.5 sha1.c, 1.3, 1.4

cras at dovecot.org cras at dovecot.org
Thu Jun 30 23:55:37 EEST 2005


Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv10026/src/lib

Modified Files:
	printf-upper-bound.c sha1.c 
Log Message:
Define I_BYTE_ORDER macro ourself because BYTE_ORDER can't seem to be relied
on. Fixes SHA1 giving wrong checksums at least in Solaris/sparc.



Index: printf-upper-bound.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/printf-upper-bound.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- printf-upper-bound.c	8 Sep 2003 01:29:07 -0000	1.4
+++ printf-upper-bound.c	30 Jun 2005 20:55:34 -0000	1.5
@@ -25,7 +25,7 @@
 #define G_IEEE754_DOUBLE_BIAS   (1023)
 /* multiply with base2 exponent to get base10 exponent (nomal numbers) */
 #define G_LOG_2_BASE_10         (0.30102999566398119521)
-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+#if I_BYTE_ORDER == LITTLE_ENDIAN
 union _GDoubleIEEE754
 {
   double v_double;
@@ -36,7 +36,7 @@
     unsigned int sign : 1;
   } mpn;
 };
-#elif G_BYTE_ORDER == G_BIG_ENDIAN
+#elif I_BYTE_ORDER == BIG_ENDIAN
 union _GDoubleIEEE754
 {
   double v_double;

Index: sha1.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/sha1.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- sha1.c	15 Sep 2004 13:19:47 -0000	1.3
+++ sha1.c	30 Jun 2005 20:55:34 -0000	1.4
@@ -38,15 +38,10 @@
 #include "sha1.h"
 #include "safe-memset.h"
 
-/* sanity check */
-#if BYTE_ORDER != BIG_ENDIAN
-# if BYTE_ORDER != LITTLE_ENDIAN
-#  define unsupported 1
-# endif
+#if I_BYTE_ORDER != LITTLE_ENDIAN && I_BYTE_ORDER != BIG_ENDIAN
+#  error unknown endian
 #endif
 
-#ifndef unsupported
-
 /* constant table */
 static uint32_t _K[] = { 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6 };
 #define	K(t)	_K[(t) / 20]
@@ -89,7 +84,7 @@
 	size_t t, s;
 	uint32_t	tmp;
 
-#if BYTE_ORDER == LITTLE_ENDIAN
+#if I_BYTE_ORDER == LITTLE_ENDIAN
 	struct sha1_ctxt tctxt;
 	memmove(&tctxt.m.b8[0], &ctxt->m.b8[0], 64);
 	ctxt->m.b8[0] = tctxt.m.b8[3]; ctxt->m.b8[1] = tctxt.m.b8[2];
@@ -198,7 +193,7 @@
 	memset(&ctxt->m.b8[padstart], 0, padlen - 8);
 	COUNT += (padlen - 8);
 	COUNT %= 64;
-#if BYTE_ORDER == BIG_ENDIAN
+#if I_BYTE_ORDER == BIG_ENDIAN
 	PUTPAD(ctxt->c.b8[0]); PUTPAD(ctxt->c.b8[1]);
 	PUTPAD(ctxt->c.b8[2]); PUTPAD(ctxt->c.b8[3]);
 	PUTPAD(ctxt->c.b8[4]); PUTPAD(ctxt->c.b8[5]);
@@ -244,7 +239,7 @@
 
 	digest = (uint8_t *)digest0;
 	sha1_pad(ctxt);
-#if BYTE_ORDER == BIG_ENDIAN
+#if I_BYTE_ORDER == BIG_ENDIAN
 	memmove(digest, &ctxt->h.b8[0], 20);
 #else
 	digest[0] = ctxt->h.b8[3]; digest[1] = ctxt->h.b8[2];
@@ -270,5 +265,3 @@
 	sha1_loop(&ctx, data, size);
 	sha1_result(&ctx, result);
 }
-
-#endif /*unsupported*/



More information about the dovecot-cvs mailing list