ext/sodium: Avoid shifts wider than 32 bits on size_t values

Backport from PECL libsodium-php 2.0.10
This commit is contained in:
Frank Denis 2018-10-14 10:21:29 +02:00
parent c25b1a7e8c
commit d057458166

View File

@ -3405,7 +3405,8 @@ PHP_FUNCTION(sodium_pad)
for (j = 0U; j <= xpadded_len; j++) {
ZSTR_VAL(padded)[j] = unpadded[i];
k -= st;
st = (~(((((k >> 48) | (k >> 32) | (k >> 16) | k) & 0xffff) - 1U) >> 16)) & 1U;
st = (size_t) (~(((( (((uint64_t) k) >> 48) | (((uint64_t) k) >> 32) |
(k >> 16) | k) & 0xffff) - 1U) >> 16)) & 1U;
i += st;
}
#if SODIUM_LIBRARY_VERSION_MAJOR > 9 || (SODIUM_LIBRARY_VERSION_MAJOR == 9 && SODIUM_LIBRARY_VERSION_MINOR >= 6)