Skip to content

Commit 2fa5592

Browse files
committed
ext/sodium: sodium_crypto_aead_(aes256gcm/aefis128l)_decrypt adjustments
a size_t could not be greater than SIZE_MAX here.
1 parent 75d7684 commit 2fa5592

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ext/sodium/libsodium.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,11 +1842,11 @@ PHP_FUNCTION(sodium_crypto_aead_aes256gcm_decrypt)
18421842
RETURN_THROWS();
18431843
}
18441844
msg_len = ciphertext_len;
1845-
if (msg_len >= SIZE_MAX) {
1845+
if (msg_len == SIZE_MAX) {
18461846
zend_throw_exception(sodium_exception_ce, "arithmetic overflow", 0);
18471847
RETURN_THROWS();
18481848
}
1849-
msg = zend_string_alloc((size_t) msg_len, 0);
1849+
msg = zend_string_alloc(msg_len, 0);
18501850
if (crypto_aead_aes256gcm_decrypt
18511851
((unsigned char *) ZSTR_VAL(msg), &msg_real_len, NULL,
18521852
ciphertext, (unsigned long long) ciphertext_len,
@@ -1957,11 +1957,11 @@ PHP_FUNCTION(sodium_crypto_aead_aegis128l_decrypt)
19571957
RETURN_FALSE;
19581958
}
19591959
msg_len = ciphertext_len;
1960-
if (msg_len >= SIZE_MAX) {
1960+
if (msg_len == SIZE_MAX) {
19611961
zend_throw_exception(sodium_exception_ce, "arithmetic overflow", 0);
19621962
RETURN_THROWS();
19631963
}
1964-
msg = zend_string_alloc((size_t) msg_len, 0);
1964+
msg = zend_string_alloc(msg_len, 0);
19651965
if (crypto_aead_aegis128l_decrypt
19661966
((unsigned char *) ZSTR_VAL(msg), &msg_real_len, NULL,
19671967
ciphertext, (unsigned long long) ciphertext_len,

0 commit comments

Comments
 (0)