Skip to content

Commit 56f4478

Browse files
committed
Re-defines SHA2 symbols so that they would not conflict with certain
versions of OpenSSL. If your OpenSSL does not contain SHA2, then there should be no conflict. But ofcourse, if someone upgrades OpenSSL, server starts crashing. Backpatched to 8.1.X. Marko Kreen
1 parent 39b031d commit 56f4478

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

contrib/pgcrypto/sha2.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
*
3434
* $From: sha2.c,v 1.1 2001/11/08 00:01:51 adg Exp adg $
3535
*
36-
* $PostgreSQL: pgsql/contrib/pgcrypto/sha2.c,v 1.5 2005/10/15 02:49:06 momjian Exp $
36+
* $PostgreSQL: pgsql/contrib/pgcrypto/sha2.c,v 1.6 2006/05/30 12:56:45 momjian Exp $
3737
*/
3838

3939
#include "postgres.h"
@@ -163,9 +163,9 @@
163163
* library -- they are intended for private internal visibility/use
164164
* only.
165165
*/
166-
void SHA512_Last(SHA512_CTX *);
167-
void SHA256_Transform(SHA256_CTX *, const uint8 *);
168-
void SHA512_Transform(SHA512_CTX *, const uint8 *);
166+
static void SHA512_Last(SHA512_CTX *);
167+
static void SHA256_Transform(SHA256_CTX *, const uint8 *);
168+
static void SHA512_Transform(SHA512_CTX *, const uint8 *);
169169

170170

171171
/*** SHA-XYZ INITIAL HASH VALUES AND CONSTANTS ************************/
@@ -307,7 +307,7 @@ SHA256_Init(SHA256_CTX * context)
307307
j++; \
308308
} while(0)
309309

310-
void
310+
static void
311311
SHA256_Transform(SHA256_CTX * context, const uint8 *data)
312312
{
313313
uint32 a,
@@ -378,7 +378,7 @@ SHA256_Transform(SHA256_CTX * context, const uint8 *data)
378378
}
379379
#else /* SHA2_UNROLL_TRANSFORM */
380380

381-
void
381+
static void
382382
SHA256_Transform(SHA256_CTX * context, const uint8 *data)
383383
{
384384
uint32 a,
@@ -631,7 +631,7 @@ SHA512_Init(SHA512_CTX * context)
631631
j++; \
632632
} while(0)
633633

634-
void
634+
static void
635635
SHA512_Transform(SHA512_CTX * context, const uint8 *data)
636636
{
637637
uint64 a,
@@ -699,7 +699,7 @@ SHA512_Transform(SHA512_CTX * context, const uint8 *data)
699699
}
700700
#else /* SHA2_UNROLL_TRANSFORM */
701701

702-
void
702+
static void
703703
SHA512_Transform(SHA512_CTX * context, const uint8 *data)
704704
{
705705
uint64 a,
@@ -842,7 +842,7 @@ SHA512_Update(SHA512_CTX * context, const uint8 *data, size_t len)
842842
usedspace = freespace = 0;
843843
}
844844

845-
void
845+
static void
846846
SHA512_Last(SHA512_CTX * context)
847847
{
848848
unsigned int usedspace;

contrib/pgcrypto/sha2.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/contrib/pgcrypto/sha2.h,v 1.2 2005/10/15 02:49:06 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/contrib/pgcrypto/sha2.h,v 1.3 2006/05/30 12:56:45 momjian Exp $ */
22
/* $OpenBSD: sha2.h,v 1.2 2004/04/28 23:11:57 millert Exp $ */
33

44
/*
@@ -38,6 +38,16 @@
3838
#ifndef _SHA2_H
3939
#define _SHA2_H
4040

41+
/* avoid conflict with OpenSSL */
42+
#define SHA256_Init pg_SHA256_Init
43+
#define SHA256_Update pg_SHA256_Update
44+
#define SHA256_Final pg_SHA256_Final
45+
#define SHA384_Init pg_SHA384_Init
46+
#define SHA384_Update pg_SHA384_Update
47+
#define SHA384_Final pg_SHA384_Final
48+
#define SHA512_Init pg_SHA512_Init
49+
#define SHA512_Update pg_SHA512_Update
50+
#define SHA512_Final pg_SHA512_Final
4151

4252
/*** SHA-256/384/512 Various Length Definitions ***********************/
4353
#define SHA256_BLOCK_LENGTH 64

0 commit comments

Comments
 (0)