Skip site navigation (1) Skip section navigation (2)

pgcrypto BYTE_ENDIAN fix

From: Marko Kreen <marko(at)l-t(dot)ee>
To: pgsql-patches(at)postgresql(dot)org
Subject: pgcrypto BYTE_ENDIAN fix
Date: 2001-11-29 19:13:18
Message-ID: 20011129211318.A27596@l-t.ee (view raw or flat)
Thread:
Lists: pgsql-patches
* When postgres.h does not define BYTE_ENDIAN pgcrypto
  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


Index: contrib/pgcrypto/blf.c
===================================================================
RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/blf.c,v
retrieving revision 1.3
diff -u -r1.3 blf.c
--- contrib/pgcrypto/blf.c	5 Nov 2001 17:46:23 -0000	1.3
+++ contrib/pgcrypto/blf.c	29 Nov 2001 11:50:37 -0000
@@ -41,6 +41,8 @@
  */
 
 #include <postgres.h>
+#include "px.h"
+
 #include "blf.h"
 
 #undef inline
Index: contrib/pgcrypto/crypt-blowfish.c
===================================================================
RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/crypt-blowfish.c,v
retrieving revision 1.6
diff -u -r1.6 crypt-blowfish.c
--- contrib/pgcrypto/crypt-blowfish.c	5 Nov 2001 17:46:23 -0000	1.6
+++ contrib/pgcrypto/crypt-blowfish.c	29 Nov 2001 11:50:10 -0000
@@ -32,7 +32,9 @@
 
 #include "postgres.h"
 
+#include "px.h"
 #include "px-crypt.h"
+
 #define __set_errno(v)
 
 #ifndef __set_errno
Index: contrib/pgcrypto/crypt-des.c
===================================================================
RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/crypt-des.c,v
retrieving revision 1.7
diff -u -r1.7 crypt-des.c
--- contrib/pgcrypto/crypt-des.c	20 Nov 2001 21:10:38 -0000	1.7
+++ contrib/pgcrypto/crypt-des.c	29 Nov 2001 11:40:16 -0000
@@ -60,6 +60,7 @@
 
 #include "postgres.h"
 
+#include "px.h"
 #include "px-crypt.h"
 
 /* for ntohl/htonl */
Index: contrib/pgcrypto/crypt-gensalt.c
===================================================================
RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/crypt-gensalt.c,v
retrieving revision 1.3
diff -u -r1.3 crypt-gensalt.c
--- contrib/pgcrypto/crypt-gensalt.c	25 Oct 2001 05:49:19 -0000	1.3
+++ contrib/pgcrypto/crypt-gensalt.c	29 Nov 2001 11:40:16 -0000
@@ -12,6 +12,7 @@
 
 #include "postgres.h"
 
+#include "px.h"
 #include "px-crypt.h"
 
 #include <errno.h>
Index: contrib/pgcrypto/md5.c
===================================================================
RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/md5.c,v
retrieving revision 1.8
diff -u -r1.8 md5.c
--- contrib/pgcrypto/md5.c	25 Oct 2001 05:49:19 -0000	1.8
+++ contrib/pgcrypto/md5.c	29 Nov 2001 11:40:53 -0000
@@ -31,6 +31,7 @@
  */
 
 #include "postgres.h"
+#include "px.h"
 
 #include "md5.h"
 
Index: contrib/pgcrypto/px.h
===================================================================
RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/px.h,v
retrieving revision 1.5
diff -u -r1.5 px.h
--- contrib/pgcrypto/px.h	20 Nov 2001 15:50:53 -0000	1.5
+++ contrib/pgcrypto/px.h	29 Nov 2001 11:41:41 -0000
@@ -32,6 +32,15 @@
 #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: contrib/pgcrypto/rijndael.c
===================================================================
RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/rijndael.c,v
retrieving revision 1.7
diff -u -r1.7 rijndael.c
--- contrib/pgcrypto/rijndael.c	20 Nov 2001 15:50:53 -0000	1.7
+++ contrib/pgcrypto/rijndael.c	29 Nov 2001 11:49:13 -0000
@@ -39,6 +39,7 @@
 */
 
 #include <postgres.h>
+#include "px.h"
 
 #include "rijndael.h"
 
Index: contrib/pgcrypto/sha1.c
===================================================================
RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/sha1.c,v
retrieving revision 1.10
diff -u -r1.10 sha1.c
--- contrib/pgcrypto/sha1.c	5 Nov 2001 17:46:23 -0000	1.10
+++ contrib/pgcrypto/sha1.c	29 Nov 2001 11:42:03 -0000
@@ -36,6 +36,7 @@
  */
 
 #include "postgres.h"
+#include "px.h"
 
 #include "sha1.h"
 

Responses

pgsql-patches by date

Next:From: Bruce MomjianDate: 2001-11-29 19:40:29
Subject: Re: pgcrypto BYTE_ENDIAN fix
Previous:From: Greg Sabino MullaneDate: 2001-11-28 22:51:22
Subject: Re: Updated version of src/bin/psql/create_help.pl

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group