Skip to content

Commit 4d97999

Browse files
committed
Address review comments
1 parent 4c65a39 commit 4d97999

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

ext/sodium/libsodium.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,11 +1611,11 @@ PHP_FUNCTION(sodium_crypto_pwhash)
16111611
RETURN_THROWS();
16121612
}
16131613
if (hash_len >= 0xffffffff) {
1614-
zend_argument_error(sodium_exception_ce, 1, "must be less than the maximum allowed value");
1614+
zend_argument_error(sodium_exception_ce, 1, "is too long");
16151615
RETURN_THROWS();
16161616
}
16171617
if (passwd_len >= 0xffffffff) {
1618-
zend_argument_error(sodium_exception_ce, 2, "must be shorter than the maximum allowed length");
1618+
zend_argument_error(sodium_exception_ce, 2, "is too long");
16191619
RETURN_THROWS();
16201620
}
16211621
if (opslimit <= 0) {
@@ -1698,7 +1698,7 @@ PHP_FUNCTION(sodium_crypto_pwhash_str)
16981698
RETURN_THROWS();
16991699
}
17001700
if (passwd_len >= 0xffffffff) {
1701-
zend_argument_error(sodium_exception_ce, 1, "must be shorter than the maximum allowed length");
1701+
zend_argument_error(sodium_exception_ce, 1, "is too long");
17021702
RETURN_THROWS();
17031703
}
17041704
if (passwd_len <= 0) {
@@ -1736,8 +1736,6 @@ PHP_FUNCTION(sodium_crypto_pwhash_str_needs_rehash)
17361736

17371737
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sll",
17381738
&hash_str, &hash_str_len, &opslimit, &memlimit) == FAILURE) {
1739-
// TODO: what's this error message here?
1740-
zend_throw_exception(sodium_exception_ce, "a PHP string is required", 0);
17411739
RETURN_THROWS();
17421740
}
17431741
if (crypto_pwhash_str_needs_rehash(hash_str, opslimit, memlimit) == 0) {
@@ -1761,7 +1759,7 @@ PHP_FUNCTION(sodium_crypto_pwhash_str_verify)
17611759
RETURN_THROWS();
17621760
}
17631761
if (passwd_len >= 0xffffffff) {
1764-
zend_argument_error(sodium_exception_ce, 2, "must be shorter than the maximum allowed length");
1762+
zend_argument_error(sodium_exception_ce, 2, "is too long");
17651763
RETURN_THROWS();
17661764
}
17671765
if (passwd_len <= 0) {
@@ -2014,7 +2012,7 @@ PHP_FUNCTION(sodium_crypto_aead_aes256gcm_decrypt)
20142012
RETURN_FALSE;
20152013
}
20162014
if (ciphertext_len - crypto_aead_aes256gcm_ABYTES > 16ULL * ((1ULL << 32) - 2ULL)) {
2017-
zend_argument_error(sodium_exception_ce, 1, "must be shorter than the maximum allowed length");
2015+
zend_argument_error(sodium_exception_ce, 1, "is too long");
20182016
RETURN_THROWS();
20192017
}
20202018
msg_len = ciphertext_len;
@@ -3106,7 +3104,7 @@ PHP_FUNCTION(sodium_pad)
31063104
RETURN_THROWS();
31073105
}
31083106
if (blocksize > SIZE_MAX) {
3109-
zend_argument_error(sodium_exception_ce, 2, "must be less than or equal to the maximum allowed value");
3107+
zend_argument_error(sodium_exception_ce, 2, "is too large");
31103108
RETURN_THROWS();
31113109
}
31123110
xpadlen = blocksize - 1U;
@@ -3179,7 +3177,7 @@ PHP_FUNCTION(sodium_unpad)
31793177
RETURN_THROWS();
31803178
}
31813179
if (blocksize > SIZE_MAX) {
3182-
zend_argument_error(sodium_exception_ce, 2, "must be less than or equal to the maximum allowed value");
3180+
zend_argument_error(sodium_exception_ce, 2, "is too large");
31833181
RETURN_THROWS();
31843182
}
31853183
if (padded_len < blocksize) {
@@ -3291,7 +3289,7 @@ PHP_FUNCTION(sodium_crypto_secretstream_xchacha20poly1305_push)
32913289
state = (unsigned char *) Z_STRVAL(*state_zv);
32923290
state_len = Z_STRLEN(*state_zv);
32933291
if (state_len != sizeof (crypto_secretstream_xchacha20poly1305_state)) {
3294-
zend_argument_error(sodium_exception_ce, 1, "to have a correct length");
3292+
zend_argument_error(sodium_exception_ce, 1, "must have a correct length");
32953293
RETURN_THROWS();
32963294
}
32973295
if (msg_len > crypto_secretstream_xchacha20poly1305_MESSAGEBYTES_MAX ||

0 commit comments

Comments
 (0)