diff --git a/contrib/pgcrypto/crypt-blowfish.c b/contrib/pgcrypto/crypt-blowfish.c index 82056a806b..1a9dba7dff 100644 --- a/contrib/pgcrypto/crypt-blowfish.c +++ b/contrib/pgcrypto/crypt-blowfish.c @@ -30,7 +30,8 @@ * hadn't seen his code). */ -#include +#include "postgres.h" + #include "px-crypt.h" #define __set_errno(v) @@ -38,13 +39,6 @@ #define __set_errno(val) errno = (val) #endif -#undef __CONST -#ifdef __GNUC__ -#define __CONST __const -#else -#define __CONST -#endif - #ifdef __i386__ #define BF_ASM 0 /* 1 */ #define BF_SCALE 1 @@ -373,7 +367,7 @@ static unsigned char BF_atoi64[0x60] = { (dst) = tmp; \ } -static int BF_decode(BF_word *dst, __CONST char *src, int size) +static int BF_decode(BF_word *dst, const char *src, int size) { unsigned char *dptr = (unsigned char *)dst; unsigned char *end = dptr + size; @@ -397,7 +391,7 @@ static int BF_decode(BF_word *dst, __CONST char *src, int size) return 0; } -static void BF_encode(char *dst, __CONST BF_word *src, int size) +static void BF_encode(char *dst, const BF_word *src, int size) { unsigned char *sptr = (unsigned char *)src; unsigned char *end = sptr + size; @@ -536,9 +530,9 @@ extern void _BF_body_r(BF_ctx *ctx); #endif -static void BF_set_key(__CONST char *key, BF_key expanded, BF_key initial) +static void BF_set_key(const char *key, BF_key expanded, BF_key initial) { - __CONST char *ptr = key; + const char *ptr = key; int i, j; BF_word tmp; @@ -556,7 +550,7 @@ static void BF_set_key(__CONST char *key, BF_key expanded, BF_key initial) } } -char *_crypt_blowfish_rn(__CONST char *key, __CONST char *setting, +char *_crypt_blowfish_rn(const char *key, const char *setting, char *output, int size) { struct { diff --git a/contrib/pgcrypto/crypt-des.c b/contrib/pgcrypto/crypt-des.c index d9e12127b7..de6b1865e3 100644 --- a/contrib/pgcrypto/crypt-des.c +++ b/contrib/pgcrypto/crypt-des.c @@ -58,18 +58,13 @@ * alignment). */ -#include +#include "postgres.h" + #include "px-crypt.h" /* for ntohl/htonl */ #include - -/* We can't always assume gcc */ -#ifdef __GNUC__ -#define INLINE inline -#endif - #define _PASSWORD_EFMT1 '_' static uint8 IP[64] = { @@ -200,7 +195,7 @@ static uint32 comp_maskl[8][128], static uint32 old_rawkey0, old_rawkey1; -static INLINE int +static inline int ascii_to_bin(char ch) { if (ch > 'z') @@ -611,6 +606,7 @@ do_des(uint32 l_in, uint32 r_in, uint32 * l_out, uint32 * r_out, int count) static int des_cipher(const char *in, char *out, long salt, int count) { + uint32 buffer[2]; uint32 l_out, r_out, rawl, @@ -622,13 +618,20 @@ des_cipher(const char *in, char *out, long salt, int count) setup_salt(salt); - rawl = ntohl(*((uint32 *) in)++); - rawr = ntohl(*((uint32 *) in)); + /* copy data to avoid assuming input is word-aligned */ + memcpy(buffer, in, sizeof(buffer)); + + rawl = ntohl(buffer[0]); + rawr = ntohl(buffer[1]); retval = do_des(rawl, rawr, &l_out, &r_out, count); - *((uint32 *) out)++ = htonl(l_out); - *((uint32 *) out) = htonl(r_out); + buffer[0] = htonl(l_out); + buffer[1] = htonl(r_out); + + /* copy data to avoid assuming output is word-aligned */ + memcpy(out, buffer, sizeof(buffer)); + return (retval); } diff --git a/contrib/pgcrypto/crypt-gensalt.c b/contrib/pgcrypto/crypt-gensalt.c index 8bb1714733..6913826842 100644 --- a/contrib/pgcrypto/crypt-gensalt.c +++ b/contrib/pgcrypto/crypt-gensalt.c @@ -10,19 +10,13 @@ * may not be compiled always. -- marko */ -#include +#include "postgres.h" + #include "px-crypt.h" #include #ifndef __set_errno -#define __set_errno(val) errno = (val) -#endif - -#undef __CONST -#ifdef __GNUC__ -#define __CONST __const -#else -#define __CONST +#define __set_errno(val) (errno = (val)) #endif typedef unsigned int BF_word; @@ -31,7 +25,7 @@ unsigned char _crypt_itoa64[64 + 1] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; char *_crypt_gensalt_traditional_rn(unsigned long count, - __CONST char *input, int size, char *output, int output_size) + const char *input, int size, char *output, int output_size) { if (size < 2 || output_size < 2 + 1 || (count && count != 25)) { if (output_size > 0) output[0] = '\0'; @@ -47,7 +41,7 @@ char *_crypt_gensalt_traditional_rn(unsigned long count, } char *_crypt_gensalt_extended_rn(unsigned long count, - __CONST char *input, int size, char *output, int output_size) + const char *input, int size, char *output, int output_size) { unsigned long value; @@ -80,7 +74,7 @@ char *_crypt_gensalt_extended_rn(unsigned long count, } char *_crypt_gensalt_md5_rn(unsigned long count, - __CONST char *input, int size, char *output, int output_size) + const char *input, int size, char *output, int output_size) { unsigned long value; @@ -121,7 +115,7 @@ char *_crypt_gensalt_md5_rn(unsigned long count, static unsigned char BF_itoa64[64 + 1] = "./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; -static void BF_encode(char *dst, __CONST BF_word *src, int size) +static void BF_encode(char *dst, const BF_word *src, int size) { unsigned char *sptr = (unsigned char *)src; unsigned char *end = sptr + size; @@ -154,7 +148,7 @@ static void BF_encode(char *dst, __CONST BF_word *src, int size) } char *_crypt_gensalt_blowfish_rn(unsigned long count, - __CONST char *input, int size, char *output, int output_size) + const char *input, int size, char *output, int output_size) { if (size < 16 || output_size < 7 + 22 + 1 || (count && (count < 4 || count > 31))) { diff --git a/contrib/pgcrypto/internal.c b/contrib/pgcrypto/internal.c index 1debd2b388..421f5f1739 100644 --- a/contrib/pgcrypto/internal.c +++ b/contrib/pgcrypto/internal.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: internal.c,v 1.4 2001/08/21 00:42:41 momjian Exp $ + * $Id: internal.c,v 1.5 2001/10/15 19:12:48 tgl Exp $ */ @@ -134,7 +134,7 @@ int_sha1_update(PX_MD * h, const uint8 * data, uint dlen) { SHA1_CTX *ctx = (SHA1_CTX *) h->p.ptr; - SHA1Update(ctx, (const char *)data, dlen); + SHA1Update(ctx, data, dlen); } static void diff --git a/contrib/rserv/rserv.c b/contrib/rserv/rserv.c index 4a7d3aed35..02c71220d6 100644 --- a/contrib/rserv/rserv.c +++ b/contrib/rserv/rserv.c @@ -87,12 +87,14 @@ _rserv_log_() if (TRIGGER_FIRED_BY_UPDATE(CurrentTriggerData->tg_event)) newtuple = CurrentTriggerData->tg_newtuple; +#ifndef PG_FUNCTION_INFO_V1 /* * Setting CurrentTriggerData to NULL prevents direct calls to trigger * functions in queries. Normally, trigger functions have to be called * by trigger manager code only. */ CurrentTriggerData = NULL; +#endif /* Connect to SPI manager */ if ((ret = SPI_connect()) < 0)