mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Add parentheses to macros when args are used in computations. Without
them, the executation behavior could be unexpected.
This commit is contained in:
@ -452,41 +452,41 @@ BF_swap(BF_word * x, int count)
|
||||
#if BF_SCALE
|
||||
/* Architectures which can shift addresses left by 2 bits with no extra cost */
|
||||
#define BF_ROUND(L, R, N) \
|
||||
tmp1 = L & 0xFF; \
|
||||
tmp2 = L >> 8; \
|
||||
tmp1 = (L) & 0xFF; \
|
||||
tmp2 = (L) >> 8; \
|
||||
tmp2 &= 0xFF; \
|
||||
tmp3 = L >> 16; \
|
||||
tmp3 = (L) >> 16; \
|
||||
tmp3 &= 0xFF; \
|
||||
tmp4 = L >> 24; \
|
||||
tmp4 = (L) >> 24; \
|
||||
tmp1 = data.ctx.S[3][tmp1]; \
|
||||
tmp2 = data.ctx.S[2][tmp2]; \
|
||||
tmp3 = data.ctx.S[1][tmp3]; \
|
||||
tmp3 += data.ctx.S[0][tmp4]; \
|
||||
tmp3 ^= tmp2; \
|
||||
R ^= data.ctx.P[N + 1]; \
|
||||
(R) ^= data.ctx.P[(N) + 1]; \
|
||||
tmp3 += tmp1; \
|
||||
R ^= tmp3;
|
||||
(R) ^= tmp3;
|
||||
#else
|
||||
/* Architectures with no complicated addressing modes supported */
|
||||
#define BF_INDEX(S, i) \
|
||||
(*((BF_word *)(((unsigned char *)S) + (i))))
|
||||
(*((BF_word *)(((unsigned char *)(S)) + (i))))
|
||||
#define BF_ROUND(L, R, N) \
|
||||
tmp1 = L & 0xFF; \
|
||||
tmp1 = (L) & 0xFF; \
|
||||
tmp1 <<= 2; \
|
||||
tmp2 = L >> 6; \
|
||||
tmp2 = (L) >> 6; \
|
||||
tmp2 &= 0x3FC; \
|
||||
tmp3 = L >> 14; \
|
||||
tmp3 = (L) >> 14; \
|
||||
tmp3 &= 0x3FC; \
|
||||
tmp4 = L >> 22; \
|
||||
tmp4 = (L) >> 22; \
|
||||
tmp4 &= 0x3FC; \
|
||||
tmp1 = BF_INDEX(data.ctx.S[3], tmp1); \
|
||||
tmp2 = BF_INDEX(data.ctx.S[2], tmp2); \
|
||||
tmp3 = BF_INDEX(data.ctx.S[1], tmp3); \
|
||||
tmp3 += BF_INDEX(data.ctx.S[0], tmp4); \
|
||||
tmp3 ^= tmp2; \
|
||||
R ^= data.ctx.P[N + 1]; \
|
||||
(R) ^= data.ctx.P[(N) + 1]; \
|
||||
tmp3 += tmp1; \
|
||||
R ^= tmp3;
|
||||
(R) ^= tmp3;
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -57,11 +57,11 @@ static void gen_tabs(void);
|
||||
|
||||
/* Invert byte order in a 32 bit variable */
|
||||
|
||||
#define bswap(x) ((rotl(x, 8) & 0x00ff00ff) | (rotr(x, 8) & 0xff00ff00))
|
||||
#define bswap(x) ((rotl((x), 8) & 0x00ff00ff) | (rotr((x), 8) & 0xff00ff00))
|
||||
|
||||
/* Extract byte from a 32 bit quantity (little endian notation) */
|
||||
|
||||
#define byte(x,n) ((u1byte)((x) >> (8 * n)))
|
||||
#define byte(x,n) ((u1byte)((x) >> (8 * (n))))
|
||||
|
||||
#if BYTE_ORDER != LITTLE_ENDIAN
|
||||
#define BYTE_SWAP
|
||||
@ -100,19 +100,19 @@ static u4byte il_tab[4][256];
|
||||
static u4byte tab_gen = 0;
|
||||
#endif /* !PRE_CALC_TABLES */
|
||||
|
||||
#define ff_mult(a,b) (a && b ? pow_tab[(log_tab[a] + log_tab[b]) % 255] : 0)
|
||||
#define ff_mult(a,b) ((a) && (b) ? pow_tab[(log_tab[a] + log_tab[b]) % 255] : 0)
|
||||
|
||||
#define f_rn(bo, bi, n, k) \
|
||||
bo[n] = ft_tab[0][byte(bi[n],0)] ^ \
|
||||
ft_tab[1][byte(bi[(n + 1) & 3],1)] ^ \
|
||||
ft_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
|
||||
ft_tab[3][byte(bi[(n + 3) & 3],3)] ^ *(k + n)
|
||||
#define f_rn(bo, bi, n, k) \
|
||||
(bo)[n] = ft_tab[0][byte((bi)[n],0)] ^ \
|
||||
ft_tab[1][byte((bi)[((n) + 1) & 3],1)] ^ \
|
||||
ft_tab[2][byte((bi)[((n) + 2) & 3],2)] ^ \
|
||||
ft_tab[3][byte((bi)[((n) + 3) & 3],3)] ^ *((k) + (n))
|
||||
|
||||
#define i_rn(bo, bi, n, k) \
|
||||
bo[n] = it_tab[0][byte(bi[n],0)] ^ \
|
||||
it_tab[1][byte(bi[(n + 3) & 3],1)] ^ \
|
||||
it_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
|
||||
it_tab[3][byte(bi[(n + 1) & 3],3)] ^ *(k + n)
|
||||
(bo)[n] = it_tab[0][byte((bi)[n],0)] ^ \
|
||||
it_tab[1][byte((bi)[((n) + 3) & 3],1)] ^ \
|
||||
it_tab[2][byte((bi)[((n) + 2) & 3],2)] ^ \
|
||||
it_tab[3][byte((bi)[((n) + 1) & 3],3)] ^ *((k) + (n))
|
||||
|
||||
#ifdef LARGE_TABLES
|
||||
|
||||
@ -122,17 +122,17 @@ static u4byte tab_gen = 0;
|
||||
fl_tab[2][byte(x, 2)] ^ \
|
||||
fl_tab[3][byte(x, 3)] )
|
||||
|
||||
#define f_rl(bo, bi, n, k) \
|
||||
bo[n] = fl_tab[0][byte(bi[n],0)] ^ \
|
||||
fl_tab[1][byte(bi[(n + 1) & 3],1)] ^ \
|
||||
fl_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
|
||||
fl_tab[3][byte(bi[(n + 3) & 3],3)] ^ *(k + n)
|
||||
#define f_rl(bo, bi, n, k) \
|
||||
(bo)[n] = fl_tab[0][byte((bi)[n],0)] ^ \
|
||||
fl_tab[1][byte((bi)[((n) + 1) & 3],1)] ^ \
|
||||
fl_tab[2][byte((bi)[((n) + 2) & 3],2)] ^ \
|
||||
fl_tab[3][byte((bi)[((n) + 3) & 3],3)] ^ *((k) + (n))
|
||||
|
||||
#define i_rl(bo, bi, n, k) \
|
||||
bo[n] = il_tab[0][byte(bi[n],0)] ^ \
|
||||
il_tab[1][byte(bi[(n + 3) & 3],1)] ^ \
|
||||
il_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
|
||||
il_tab[3][byte(bi[(n + 1) & 3],3)] ^ *(k + n)
|
||||
#define i_rl(bo, bi, n, k) \
|
||||
(bo)[n] = il_tab[0][byte((bi)[n],0)] ^ \
|
||||
il_tab[1][byte((bi)[((n) + 3) & 3],1)] ^ \
|
||||
il_tab[2][byte((bi)[((n) + 2) & 3],2)] ^ \
|
||||
il_tab[3][byte((bi)[((n) + 1) & 3],3)] ^ *((k) + (n))
|
||||
|
||||
#else
|
||||
|
||||
@ -142,17 +142,17 @@ static u4byte tab_gen = 0;
|
||||
((u4byte)sbx_tab[byte(x, 2)] << 16) ^ \
|
||||
((u4byte)sbx_tab[byte(x, 3)] << 24)
|
||||
|
||||
#define f_rl(bo, bi, n, k) \
|
||||
bo[n] = (u4byte)sbx_tab[byte(bi[n],0)] ^ \
|
||||
rotl(((u4byte)sbx_tab[byte(bi[(n + 1) & 3],1)]), 8) ^ \
|
||||
rotl(((u4byte)sbx_tab[byte(bi[(n + 2) & 3],2)]), 16) ^ \
|
||||
rotl(((u4byte)sbx_tab[byte(bi[(n + 3) & 3],3)]), 24) ^ *(k + n)
|
||||
#define f_rl(bo, bi, n, k) \
|
||||
(bo)[n] = (u4byte)sbx_tab[byte((bi)[n],0)] ^ \
|
||||
rotl(((u4byte)sbx_tab[byte((bi)[((n) + 1) & 3],1)]), 8) ^ \
|
||||
rotl(((u4byte)sbx_tab[byte((bi)[((n) + 2) & 3],2)]), 16) ^ \
|
||||
rotl(((u4byte)sbx_tab[byte((bi)[((n) + 3) & 3],3)]), 24) ^ *((k) + (n))
|
||||
|
||||
#define i_rl(bo, bi, n, k) \
|
||||
bo[n] = (u4byte)isb_tab[byte(bi[n],0)] ^ \
|
||||
rotl(((u4byte)isb_tab[byte(bi[(n + 3) & 3],1)]), 8) ^ \
|
||||
rotl(((u4byte)isb_tab[byte(bi[(n + 2) & 3],2)]), 16) ^ \
|
||||
rotl(((u4byte)isb_tab[byte(bi[(n + 1) & 3],3)]), 24) ^ *(k + n)
|
||||
#define i_rl(bo, bi, n, k) \
|
||||
(bo)[n] = (u4byte)isb_tab[byte((bi)[n],0)] ^ \
|
||||
rotl(((u4byte)isb_tab[byte((bi)[((n) + 3) & 3],1)]), 8) ^ \
|
||||
rotl(((u4byte)isb_tab[byte((bi)[((n) + 2) & 3],2)]), 16) ^ \
|
||||
rotl(((u4byte)isb_tab[byte((bi)[((n) + 1) & 3],3)]), 24) ^ *((k) + (n))
|
||||
#endif
|
||||
|
||||
static void
|
||||
@ -282,25 +282,25 @@ do { t = ls_box(rotr(t, 8)) ^ rco_tab[i]; \
|
||||
|
||||
#define loop6(i) \
|
||||
do { t = ls_box(rotr(t, 8)) ^ rco_tab[i]; \
|
||||
t ^= e_key[6 * i]; e_key[6 * i + 6] = t; \
|
||||
t ^= e_key[6 * i + 1]; e_key[6 * i + 7] = t; \
|
||||
t ^= e_key[6 * i + 2]; e_key[6 * i + 8] = t; \
|
||||
t ^= e_key[6 * i + 3]; e_key[6 * i + 9] = t; \
|
||||
t ^= e_key[6 * i + 4]; e_key[6 * i + 10] = t; \
|
||||
t ^= e_key[6 * i + 5]; e_key[6 * i + 11] = t; \
|
||||
t ^= e_key[6 * (i)]; e_key[6 * (i) + 6] = t; \
|
||||
t ^= e_key[6 * (i) + 1]; e_key[6 * (i) + 7] = t; \
|
||||
t ^= e_key[6 * (i) + 2]; e_key[6 * (i) + 8] = t; \
|
||||
t ^= e_key[6 * (i) + 3]; e_key[6 * (i) + 9] = t; \
|
||||
t ^= e_key[6 * (i) + 4]; e_key[6 * (i) + 10] = t; \
|
||||
t ^= e_key[6 * (i) + 5]; e_key[6 * (i) + 11] = t; \
|
||||
} while (0)
|
||||
|
||||
#define loop8(i) \
|
||||
do { t = ls_box(rotr(t, 8)) ^ rco_tab[i]; \
|
||||
t ^= e_key[8 * i]; e_key[8 * i + 8] = t; \
|
||||
t ^= e_key[8 * i + 1]; e_key[8 * i + 9] = t; \
|
||||
t ^= e_key[8 * i + 2]; e_key[8 * i + 10] = t; \
|
||||
t ^= e_key[8 * i + 3]; e_key[8 * i + 11] = t; \
|
||||
t = e_key[8 * i + 4] ^ ls_box(t); \
|
||||
e_key[8 * i + 12] = t; \
|
||||
t ^= e_key[8 * i + 5]; e_key[8 * i + 13] = t; \
|
||||
t ^= e_key[8 * i + 6]; e_key[8 * i + 14] = t; \
|
||||
t ^= e_key[8 * i + 7]; e_key[8 * i + 15] = t; \
|
||||
t ^= e_key[8 * (i)]; e_key[8 * (i) + 8] = t; \
|
||||
t ^= e_key[8 * (i) + 1]; e_key[8 * (i) + 9] = t; \
|
||||
t ^= e_key[8 * (i) + 2]; e_key[8 * (i) + 10] = t; \
|
||||
t ^= e_key[8 * (i) + 3]; e_key[8 * (i) + 11] = t; \
|
||||
t = e_key[8 * (i) + 4] ^ ls_box(t); \
|
||||
e_key[8 * (i) + 12] = t; \
|
||||
t ^= e_key[8 * (i) + 5]; e_key[8 * (i) + 13] = t; \
|
||||
t ^= e_key[8 * (i) + 6]; e_key[8 * (i) + 14] = t; \
|
||||
t ^= e_key[8 * (i) + 7]; e_key[8 * (i) + 15] = t; \
|
||||
} while (0)
|
||||
|
||||
rijndael_ctx *
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/contrib/pgcrypto/sha1.c,v 1.14 2004/08/29 16:43:05 tgl Exp $ */
|
||||
/* $PostgreSQL: pgsql/contrib/pgcrypto/sha1.c,v 1.15 2005/05/25 21:40:39 momjian Exp $ */
|
||||
/* $KAME: sha1.c,v 1.3 2000/02/22 14:01:18 itojun Exp $ */
|
||||
|
||||
/*
|
||||
@ -59,7 +59,7 @@ static uint32 _K[] = {0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6};
|
||||
#define F2(b, c, d) (((b) & (c)) | ((b) & (d)) | ((c) & (d)))
|
||||
#define F3(b, c, d) (((b) ^ (c)) ^ (d))
|
||||
|
||||
#define S(n, x) (((x) << (n)) | ((x) >> (32 - n)))
|
||||
#define S(n, x) (((x) << (n)) | ((x) >> (32 - (n))))
|
||||
|
||||
#define H(n) (ctxt->h.b32[(n)])
|
||||
#define COUNT (ctxt->count)
|
||||
|
Reference in New Issue
Block a user