* When postgres.h does not define BYTE_ENDIAN pgcrypto
authorBruce Momjian <[email protected]>
Thu, 29 Nov 2001 19:40:37 +0000 (19:40 +0000)
committerBruce Momjian <[email protected]>
Thu, 29 Nov 2001 19:40:37 +0000 (19:40 +0000)
  produces garbage.

I learned the hard way that

        #if UNDEFINED_1 == UNDEFINED_2
        #error "gcc is idiot"
        #endif

prints "gcc is idiot" ...

Affected are MD5/SHA1 in internal library, and also HMAC-MD5/HMAC-SHA1/
crypt-md5 which use them.  Blowfish is ok, also Rijndael on at
least x86.

Big thanks to Daniel Holtzman who send me a build log which
contained warning:

        md5.c:246: warning: `X' defined but not used

Yes, gcc is that helpful...

Please apply this.

--
marko

contrib/pgcrypto/blf.c
contrib/pgcrypto/crypt-blowfish.c
contrib/pgcrypto/crypt-des.c
contrib/pgcrypto/crypt-gensalt.c
contrib/pgcrypto/md5.c
contrib/pgcrypto/px.h
contrib/pgcrypto/rijndael.c
contrib/pgcrypto/sha1.c

index efba19055ff3a560eabc0c8c3646ada09aa51575..0caa33d4e321d49b4a0aee2b65433cae9993c30a 100644 (file)
@@ -41,6 +41,8 @@
  */
 
 #include <postgres.h>
+#include "px.h"
+
 #include "blf.h"
 
 #undef inline
index 8ec2b188e04260d9491921757d129328b61765bf..8e41771be98dcdac1cfbb23063c7386d2b049d56 100644 (file)
@@ -32,7 +32,9 @@
 
 #include "postgres.h"
 
+#include "px.h"
 #include "px-crypt.h"
+
 #define __set_errno(v)
 
 #ifndef __set_errno
index 53df2a19fb753a5dd1cb8c053091c9e236ef0a3b..bcb6b5b5c71c7b96b4db7625d442baeac9e08ae3 100644 (file)
@@ -60,6 +60,7 @@
 
 #include "postgres.h"
 
+#include "px.h"
 #include "px-crypt.h"
 
 /* for ntohl/htonl */
index 9c017b0e4d0e755fc0afabd82ce03a6b43dde421..c58e794789fd45d83860d410f9339a7bb2ac5f31 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "postgres.h"
 
+#include "px.h"
 #include "px-crypt.h"
 
 #include <errno.h>
index 6a37f2f8ec6076a0cdaddcb8476a7a31c3ef57be..e66e21a6ed16e2229ba975cbc517a16764505edc 100644 (file)
@@ -31,6 +31,7 @@
  */
 
 #include "postgres.h"
+#include "px.h"
 
 #include "md5.h"
 
index d8252a5a9184d670ec0ff05e66ac1ac14f2d9701..4e22245d3ecb71d886902ed352036711a56fb842 100644 (file)
 #ifndef __PX_H
 #define __PX_H
 
+#ifdef HAVE_ENDIAN_H
+#include <endian.h>
+#endif
+
+#ifndef BYTE_ORDER
+#error BYTE_ORDER must be defined as LITTLE_ENDIAN or BIG_ENDIAN
+#endif
+
+
 #if 1
 
 #define px_alloc(s) palloc(s)
index c534f58cd8b6ece7a44715234cec77862da8603e..094f4a8fa545a22626f04118c1555e0bed1b8c63 100644 (file)
@@ -39,6 +39,7 @@ Mean:            500 cycles =    51.2 mbits/sec
 */
 
 #include <postgres.h>
+#include "px.h"
 
 #include "rijndael.h"
 
index 1c1a1d5f90bec5e87551fc0ad22e6ada2ddff435..5be954d76942ed0ee51e6198851243e17e8a3237 100644 (file)
@@ -36,6 +36,7 @@
  */
 
 #include "postgres.h"
+#include "px.h"
 
 #include "sha1.h"