Skip to content

Commit bf48d0c

Browse files
committed
ext/sodium: Fix sodium_pad() with blocksize >= 256
Backport from PECL libsodium-php 2.0.12
1 parent 15ba7df commit bf48d0c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ext/sodium/libsodium.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3424,7 +3424,8 @@ PHP_FUNCTION(sodium_pad)
34243424
tail = &ZSTR_VAL(padded)[xpadded_len];
34253425
mask = 0U;
34263426
for (i = 0; i < blocksize; i++) {
3427-
barrier_mask = (unsigned char) (((i ^ xpadlen) - 1U) >> 8);
3427+
barrier_mask = (unsigned char)
3428+
(((i ^ xpadlen) - 1U) >> ((sizeof(size_t) - 1U) * CHAR_BIT));
34283429
tail[-i] = (tail[-i] & mask) | (0x80 & barrier_mask);
34293430
mask |= barrier_mask;
34303431
}

0 commit comments

Comments
 (0)