Skip to content

Commit 0f6d3dc

Browse files
committed
apply @nielsdos suggestion instead.
to potentially protect against buffer overflow.
1 parent 2fa5592 commit 0f6d3dc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ext/sodium/libsodium.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,7 +1842,7 @@ 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 >= ZSTR_MAX_LEN) {
18461846
zend_throw_exception(sodium_exception_ce, "arithmetic overflow", 0);
18471847
RETURN_THROWS();
18481848
}
@@ -1957,7 +1957,7 @@ 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 >= ZSTR_MAX_LEN) {
19611961
zend_throw_exception(sodium_exception_ce, "arithmetic overflow", 0);
19621962
RETURN_THROWS();
19631963
}

0 commit comments

Comments
 (0)