Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfb473bc

Browse files
committed
Fix unsafe macro definitions (which were producing incorrect code,
leading to compile warnings).
1 parentda2e0dd commitfb473bc

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

‎contrib/pgcrypto/rijndael.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,14 +259,16 @@ gen_tabs(void)
259259
#definestar_x(x) (((x) & 0x7f7f7f7f) << 1) ^ ((((x) & 0x80808080) >> 7) * 0x1b)
260260

261261
#defineimix_col(y,x)\
262+
do { \
262263
u= star_x(x);\
263264
v= star_x(u);\
264265
w= star_x(v);\
265266
t= w ^ (x);\
266267
(y)= u ^ v ^ w;\
267268
(y) ^= rotr(u ^ t, 8) ^ \
268269
rotr(v ^ t, 16) ^ \
269-
rotr(t,24)
270+
rotr(t,24);\
271+
} while (0)
270272

271273
/* initialise the key schedule from the user supplied key*/
272274

@@ -367,17 +369,21 @@ rijndael_set_key(rijndael_ctx * ctx, const u4byte * in_key, const u4byte key_len
367369
/* encrypt a block of text*/
368370

369371
#definef_nround(bo,bi,k) \
372+
do { \
370373
f_rn(bo, bi, 0, k);\
371374
f_rn(bo, bi, 1, k);\
372375
f_rn(bo, bi, 2, k);\
373376
f_rn(bo, bi, 3, k);\
374-
k += 4
377+
k += 4;\
378+
} while (0)
375379

376380
#definef_lround(bo,bi,k) \
381+
do { \
377382
f_rl(bo, bi, 0, k);\
378383
f_rl(bo, bi, 1, k);\
379384
f_rl(bo, bi, 2, k);\
380-
f_rl(bo, bi, 3, k)
385+
f_rl(bo, bi, 3, k);\
386+
} while (0)
381387

382388
void
383389
rijndael_encrypt(rijndael_ctx*ctx,constu4byte*in_blk,u4byte*out_blk)
@@ -427,17 +433,21 @@ rijndael_encrypt(rijndael_ctx * ctx, const u4byte * in_blk, u4byte * out_blk)
427433
/* decrypt a block of text*/
428434

429435
#definei_nround(bo,bi,k) \
436+
do { \
430437
i_rn(bo, bi, 0, k);\
431438
i_rn(bo, bi, 1, k);\
432439
i_rn(bo, bi, 2, k);\
433440
i_rn(bo, bi, 3, k);\
434-
k -= 4
441+
k -= 4;\
442+
} while (0)
435443

436444
#definei_lround(bo,bi,k) \
445+
do { \
437446
i_rl(bo, bi, 0, k);\
438447
i_rl(bo, bi, 1, k);\
439448
i_rl(bo, bi, 2, k);\
440-
i_rl(bo, bi, 3, k)
449+
i_rl(bo, bi, 3, k);\
450+
} while (0)
441451

442452
void
443453
rijndael_decrypt(rijndael_ctx*ctx,constu4byte*in_blk,u4byte*out_blk)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp