Mercurial > vim
comparison src/sha256.c @ 27752:c1d1639b52dd v8.2.4402
patch 8.2.4402: missing parenthesis may cause unexpected problems
Commit: https://github.com/vim/vim/commit/ae6f1d8b14c2f63811ee83ef14e32086fb3e9b83
Author: kylo252 <59826753+kylo252@users.noreply.github.com>
Date: Wed Feb 16 19:24:07 2022 +0000
patch 8.2.4402: missing parenthesis may cause unexpected problems
Problem: Missing parenthesis may cause unexpected problems.
Solution: Add more parenthesis is macros. (closes https://github.com/vim/vim/issues/9788)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 16 Feb 2022 20:30:03 +0100 |
parents | d34ec6fe207d |
children |
comparison
equal
deleted
inserted
replaced
27751:c9330d10419b | 27752:c1d1639b52dd |
---|---|
77 GET_UINT32(W[12], data, 48); | 77 GET_UINT32(W[12], data, 48); |
78 GET_UINT32(W[13], data, 52); | 78 GET_UINT32(W[13], data, 52); |
79 GET_UINT32(W[14], data, 56); | 79 GET_UINT32(W[14], data, 56); |
80 GET_UINT32(W[15], data, 60); | 80 GET_UINT32(W[15], data, 60); |
81 | 81 |
82 #define SHR(x, n) ((x & 0xFFFFFFFF) >> n) | 82 #define SHR(x, n) (((x) & 0xFFFFFFFF) >> (n)) |
83 #define ROTR(x, n) (SHR(x, n) | (x << (32 - n))) | 83 #define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n)))) |
84 | 84 |
85 #define S0(x) (ROTR(x, 7) ^ ROTR(x, 18) ^ SHR(x, 3)) | 85 #define S0(x) (ROTR(x, 7) ^ ROTR(x, 18) ^ SHR(x, 3)) |
86 #define S1(x) (ROTR(x, 17) ^ ROTR(x, 19) ^ SHR(x, 10)) | 86 #define S1(x) (ROTR(x, 17) ^ ROTR(x, 19) ^ SHR(x, 10)) |
87 | 87 |
88 #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22)) | 88 #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22)) |
89 #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25)) | 89 #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25)) |
90 | 90 |
91 #define F0(x, y, z) ((x & y) | (z & (x | y))) | 91 #define F0(x, y, z) (((x) & (y)) | ((z) & ((x) | (y)))) |
92 #define F1(x, y, z) (z ^ (x & (y ^ z))) | 92 #define F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) |
93 | 93 |
94 #define R(t) \ | 94 #define R(t) \ |
95 ( \ | 95 ( \ |
96 W[t] = S1(W[t - 2]) + W[t - 7] + \ | 96 W[t] = S1(W[(t) - 2]) + W[(t) - 7] + \ |
97 S0(W[t - 15]) + W[t - 16] \ | 97 S0(W[(t) - 15]) + W[(t) - 16] \ |
98 ) | 98 ) |
99 | 99 |
100 #define P(a,b,c,d,e,f,g,h,x,K) \ | 100 #define P(a,b,c,d,e,f,g,h,x,K) \ |
101 { \ | 101 { \ |
102 temp1 = h + S3(e) + F1(e, f, g) + K + x; \ | 102 temp1 = (h) + S3(e) + F1(e, f, g) + (K) + (x); \ |
103 temp2 = S2(a) + F0(a, b, c); \ | 103 temp2 = S2(a) + F0(a, b, c); \ |
104 d += temp1; h = temp1 + temp2; \ | 104 (d) += temp1; (h) = temp1 + temp2; \ |
105 } | 105 } |
106 | 106 |
107 A = ctx->state[0]; | 107 A = ctx->state[0]; |
108 B = ctx->state[1]; | 108 B = ctx->state[1]; |
109 C = ctx->state[2]; | 109 C = ctx->state[2]; |