From d05745816634d82a14bb8abb9c322c8b63be098f Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sun, 14 Oct 2018 10:21:29 +0200 Subject: [PATCH] ext/sodium: Avoid shifts wider than 32 bits on size_t values Backport from PECL libsodium-php 2.0.10 --- ext/sodium/libsodium.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/sodium/libsodium.c b/ext/sodium/libsodium.c index e168aad105d..08ac0f9ab21 100644 --- a/ext/sodium/libsodium.c +++ b/ext/sodium/libsodium.c @@ -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)