Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e997758

Browse files
committed
More pgcrypto fixes: avoid bogus alignment assumptions in sha2,
be more wary about having a value for BYTE_ORDER, clean up randomly- chosen ways of including Postgres core headers. Marko Kreen and Tom Lane
1 parent 3c52d17 commit e997758

29 files changed

+99
-90
lines changed

contrib/pgcrypto/blf.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3232
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3333
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34+
*
35+
* $PostgreSQL: pgsql/contrib/pgcrypto/blf.c,v 1.7 2005/07/11 15:07:59 tgl Exp $
3436
*/
3537

3638
/*
@@ -40,9 +42,9 @@
4042
* Bruce Schneier.
4143
*/
4244

43-
#include <postgres.h>
44-
#include "px.h"
45+
#include "postgres.h"
4546

47+
#include "px.h"
4648
#include "blf.h"
4749

4850
/* Function for Feistel Networks */

contrib/pgcrypto/crypt-md5.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
*
99
* $FreeBSD: src/lib/libcrypt/crypt-md5.c,v 1.5 1999/12/17 20:21:45 peter Exp $
1010
*
11+
* $PostgreSQL: pgsql/contrib/pgcrypto/crypt-md5.c,v 1.4 2005/07/11 15:07:59 tgl Exp $
1112
*/
12-
/* $PostgreSQL: pgsql/contrib/pgcrypto/crypt-md5.c,v 1.3 2003/11/29 22:39:28 pgsql Exp $ */
1313

14-
#include <postgres.h>
14+
#include "postgres.h"
15+
1516
#include "px.h"
1617
#include "px-crypt.h"
1718

contrib/pgcrypto/fortuna.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $PostgreSQL: pgsql/contrib/pgcrypto/fortuna.c,v 1.1 2005/07/10 13:46:27 momjian Exp $
29+
* $PostgreSQL: pgsql/contrib/pgcrypto/fortuna.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
3030
*/
3131

32-
#include <postgres.h>
32+
#include "postgres.h"
33+
3334
#include <sys/time.h>
3435
#include <time.h>
3536

3637
#include "rijndael.h"
3738
#include "sha2.h"
38-
3939
#include "fortuna.h"
4040

4141

contrib/pgcrypto/internal.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $PostgreSQL: pgsql/contrib/pgcrypto/internal.c,v 1.19 2005/07/10 17:22:54 tgl Exp $
29+
* $PostgreSQL: pgsql/contrib/pgcrypto/internal.c,v 1.20 2005/07/11 15:07:59 tgl Exp $
3030
*/
3131

32+
#include "postgres.h"
3233

33-
#include <postgres.h>
3434
#include <time.h>
3535

3636
#include "px.h"
37-
3837
#include "md5.h"
3938
#include "sha1.h"
4039
#include "sha2.h"

contrib/pgcrypto/mbuf.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $PostgreSQL: pgsql/contrib/pgcrypto/mbuf.c,v 1.1 2005/07/10 13:46:28 momjian Exp $
29+
* $PostgreSQL: pgsql/contrib/pgcrypto/mbuf.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
3030
*/
3131

32-
#include <postgres.h>
32+
#include "postgres.h"
3333

3434
#include "px.h"
3535
#include "mbuf.h"

contrib/pgcrypto/md5.c

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* $PostgreSQL: pgsql/contrib/pgcrypto/md5.c,v 1.12 2004/08/29 16:43:05 tgl Exp $ */
21
/* $KAME: md5.c,v 1.3 2000/02/22 14:01:17 itojun Exp $ */
32

43
/*
@@ -28,13 +27,22 @@
2827
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2928
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3029
* SUCH DAMAGE.
30+
*
31+
* $PostgreSQL: pgsql/contrib/pgcrypto/md5.c,v 1.13 2005/07/11 15:07:59 tgl Exp $
3132
*/
3233

3334
#include "postgres.h"
34-
#include "px.h"
3535

36+
#include <sys/param.h>
37+
38+
#include "px.h"
3639
#include "md5.h"
3740

41+
/* sanity check */
42+
#if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN)
43+
#error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN
44+
#endif
45+
3846
#define SHIFT(X, s) (((X) << (s)) | ((X) >> (32 - (s))))
3947

4048
#define F(X, Y, Z) (((X) & (Y)) | ((~X) & (Z)))

contrib/pgcrypto/openssl.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $PostgreSQL: pgsql/contrib/pgcrypto/openssl.c,v 1.23 2005/07/11 14:38:05 tgl Exp $
29+
* $PostgreSQL: pgsql/contrib/pgcrypto/openssl.c,v 1.24 2005/07/11 15:07:59 tgl Exp $
3030
*/
3131

32-
#include <postgres.h>
32+
#include "postgres.h"
3333

3434
#include "px.h"
3535

contrib/pgcrypto/pgp-armor.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-armor.c,v 1.1 2005/07/10 13:46:28 momjian Exp $
29+
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-armor.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
3030
*/
3131

32-
#include <postgres.h>
33-
34-
#include <string.h>
32+
#include "postgres.h"
3533

3634
#include "px.h"
3735
#include "mbuf.h"

contrib/pgcrypto/pgp-cfb.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-cfb.c,v 1.1 2005/07/10 13:46:28 momjian Exp $
29+
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-cfb.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
3030
*/
3131

32-
#include <postgres.h>
32+
#include "postgres.h"
33+
3334
#include "mbuf.h"
3435
#include "px.h"
3536
#include "pgp.h"

contrib/pgcrypto/pgp-compress.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-compress.c,v 1.1 2005/07/10 13:46:28 momjian Exp $
29+
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-compress.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
3030
*/
3131

32-
#include <postgres.h>
32+
#include "postgres.h"
3333

3434
#include "mbuf.h"
3535
#include "px.h"
@@ -43,6 +43,7 @@
4343
#ifndef DISABLE_ZLIB
4444

4545
#include <zlib.h>
46+
4647
#define ZIP_OUT_BUF 8192
4748
#define ZIP_IN_BLOCK 8192
4849

contrib/pgcrypto/pgp-decrypt.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-decrypt.c,v 1.1 2005/07/10 13:46:28 momjian Exp $
29+
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-decrypt.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
3030
*/
3131

32-
#include <postgres.h>
32+
#include "postgres.h"
3333

3434
#include "px.h"
3535
#include "mbuf.h"

contrib/pgcrypto/pgp-encrypt.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-encrypt.c,v 1.1 2005/07/10 13:46:28 momjian Exp $
29+
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-encrypt.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
3030
*/
3131

32-
#include <postgres.h>
32+
#include "postgres.h"
33+
3334
#include <time.h>
3435

3536
#include "mbuf.h"

contrib/pgcrypto/pgp-info.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-info.c,v 1.1 2005/07/10 13:46:28 momjian Exp $
29+
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-info.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
3030
*/
31-
#include <postgres.h>
31+
#include "postgres.h"
3232

3333
#include "px.h"
3434
#include "mbuf.h"

contrib/pgcrypto/pgp-mpi-internal.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-mpi-internal.c,v 1.1 2005/07/10 13:46:28 momjian Exp $
29+
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-mpi-internal.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
3030
*/
31-
#include <postgres.h>
31+
#include "postgres.h"
3232

3333
#include "px.h"
3434
#include "mbuf.h"

contrib/pgcrypto/pgp-mpi-openssl.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-mpi-openssl.c,v 1.1 2005/07/10 13:46:29 momjian Exp $
29+
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-mpi-openssl.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
3030
*/
31-
#include <postgres.h>
31+
#include "postgres.h"
3232

3333
#include <openssl/bn.h>
3434

contrib/pgcrypto/pgp-mpi.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-mpi.c,v 1.1 2005/07/10 13:46:29 momjian Exp $
29+
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-mpi.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
3030
*/
31-
#include <postgres.h>
31+
#include "postgres.h"
3232

3333
#include "px.h"
3434
#include "mbuf.h"

contrib/pgcrypto/pgp-pgsql.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pgsql.c,v 1.1 2005/07/10 13:46:29 momjian Exp $
29+
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pgsql.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
3030
*/
3131

32-
#include <postgres.h>
33-
#include <fmgr.h>
34-
#include <parser/scansup.h>
35-
#include <mb/pg_wchar.h>
32+
#include "postgres.h"
33+
34+
#include "fmgr.h"
35+
#include "parser/scansup.h"
36+
#include "mb/pg_wchar.h"
3637

3738
#include "mbuf.h"
3839
#include "px.h"

contrib/pgcrypto/pgp-pubdec.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pubdec.c,v 1.2 2005/07/10 15:37:03 momjian Exp $
29+
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pubdec.c,v 1.3 2005/07/11 15:07:59 tgl Exp $
3030
*/
31-
#include <postgres.h>
31+
#include "postgres.h"
3232

3333
#include "px.h"
3434
#include "mbuf.h"

contrib/pgcrypto/pgp-pubenc.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pubenc.c,v 1.1 2005/07/10 13:46:29 momjian Exp $
29+
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pubenc.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
3030
*/
31-
#include <postgres.h>
31+
#include "postgres.h"
3232

3333
#include "px.h"
3434
#include "mbuf.h"

contrib/pgcrypto/pgp-pubkey.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pubkey.c,v 1.1 2005/07/10 13:46:29 momjian Exp $
29+
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pubkey.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
3030
*/
31-
#include <postgres.h>
31+
#include "postgres.h"
3232

3333
#include "px.h"
3434
#include "mbuf.h"

contrib/pgcrypto/pgp-s2k.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-s2k.c,v 1.1 2005/07/10 13:46:29 momjian Exp $
29+
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-s2k.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
3030
*/
3131

32-
#include <postgres.h>
32+
#include "postgres.h"
3333

3434
#include "px.h"
3535
#include "mbuf.h"

contrib/pgcrypto/pgp.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp.c,v 1.1 2005/07/10 13:46:29 momjian Exp $
29+
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
3030
*/
3131

32-
#include <postgres.h>
32+
#include "postgres.h"
3333

3434
#include "px.h"
3535
#include "mbuf.h"

contrib/pgcrypto/px-crypt.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $PostgreSQL: pgsql/contrib/pgcrypto/px-crypt.c,v 1.11 2005/03/21 05:22:14 neilc Exp $
29+
* $PostgreSQL: pgsql/contrib/pgcrypto/px-crypt.c,v 1.12 2005/07/11 15:07:59 tgl Exp $
3030
*/
3131

32-
#include <postgres.h>
32+
#include "postgres.h"
33+
3334
#include "px.h"
3435
#include "px-crypt.h"
3536

contrib/pgcrypto/px-hmac.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $PostgreSQL: pgsql/contrib/pgcrypto/px-hmac.c,v 1.6 2005/03/21 05:19:55 neilc Exp $
29+
* $PostgreSQL: pgsql/contrib/pgcrypto/px-hmac.c,v 1.7 2005/07/11 15:07:59 tgl Exp $
3030
*/
3131

32-
33-
#include <postgres.h>
32+
#include "postgres.h"
3433

3534
#include "px.h"
3635

contrib/pgcrypto/px.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $PostgreSQL: pgsql/contrib/pgcrypto/px.c,v 1.12 2005/07/10 03:57:55 momjian Exp $
29+
* $PostgreSQL: pgsql/contrib/pgcrypto/px.c,v 1.13 2005/07/11 15:07:59 tgl Exp $
3030
*/
3131

32-
#include <postgres.h>
32+
#include "postgres.h"
3333

3434
#include "px.h"
3535

contrib/pgcrypto/random.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $PostgreSQL: pgsql/contrib/pgcrypto/random.c,v 1.11 2005/07/10 03:55:28 momjian Exp $
29+
* $PostgreSQL: pgsql/contrib/pgcrypto/random.c,v 1.12 2005/07/11 15:07:59 tgl Exp $
3030
*/
3131

32-
33-
#include <postgres.h>
32+
#include "postgres.h"
3433

3534
#include "px.h"
3635

@@ -49,7 +48,6 @@
4948

5049
#define TRY_DEV_RANDOM
5150

52-
#include <errno.h>
5351
#include <fcntl.h>
5452
#include <unistd.h>
5553

0 commit comments

Comments
 (0)