From: Frank Denis Date: Tue, 8 Aug 2017 15:34:20 +0000 (+0200) Subject: sodium ext: Add missing "return" statements after zend_throw_exception() X-Git-Tag: php-7.2.0beta3~36 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3140d40421467ca95655dde09aa1c478ce2f2402;p=php sodium ext: Add missing "return" statements after zend_throw_exception() --- diff --git a/ext/sodium/libsodium.c b/ext/sodium/libsodium.c index 9580e3f28d..48902744a5 100644 --- a/ext/sodium/libsodium.c +++ b/ext/sodium/libsodium.c @@ -621,6 +621,7 @@ PHP_FUNCTION(sodium_memcmp) } if (len1 != len2) { zend_throw_exception(sodium_exception_ce, "arguments have different sizes", 0); + return; } else { RETURN_LONG(sodium_memcmp(buf1, buf2, len1)); } @@ -2860,6 +2861,7 @@ PHP_FUNCTION(sodium_compare) } if (len1 != len2) { zend_throw_exception(sodium_exception_ce, "arguments have different sizes", 0); + return; } else { RETURN_LONG(sodium_compare((const unsigned char *) buf1, (const unsigned char *) buf2, (size_t) len1)); @@ -3002,18 +3004,23 @@ PHP_FUNCTION(sodium_crypto_kdf_derive_from_key) } if (subkey_len < crypto_kdf_BYTES_MIN) { zend_throw_exception(sodium_exception_ce, "subkey cannot be smaller than sodium_crypto_kdf_BYTES_MIN", 0); + return; } if (subkey_len > crypto_kdf_BYTES_MAX) { zend_throw_exception(sodium_exception_ce, "subkey cannot be larger than sodium_crypto_kdf_BYTES_MAX", 0); + return; } if (subkey_id < 0) { zend_throw_exception(sodium_exception_ce, "subkey_id cannot be negative", 0); + return; } if (ctx_len != crypto_kdf_CONTEXTBYTES) { zend_throw_exception(sodium_exception_ce, "context should be sodium_crypto_kdf_CONTEXTBYTES bytes", 0); + return; } if (key_len != crypto_kdf_KEYBYTES) { zend_throw_exception(sodium_exception_ce, "key should be sodium_crypto_kdf_KEYBYTES bytes", 0); + return; } memcpy(ctx_padded, ctx, crypto_kdf_CONTEXTBYTES); memset(ctx_padded + crypto_kdf_CONTEXTBYTES, 0, sizeof ctx_padded - crypto_kdf_CONTEXTBYTES); @@ -3034,6 +3041,7 @@ PHP_FUNCTION(sodium_crypto_kdf_derive_from_key) crypto_kdf_KEYBYTES, salt, ctx_padded) != 0) { zend_throw_exception(sodium_exception_ce, "internal error", 0); + return; } ZSTR_VAL(subkey)[subkey_len] = 0;