if (!php_phongo_bson_to_zval_ex(&(reply), &state)) { \
zval_ptr_dtor(&state.zchild); \
goto cleanup; \
} \
RETVAL_ZVAL(&state.zchild, 0, 1); \
} while (0)
#define RETVAL_OPTIONAL_BSON_T(reply) \
do { \
RETVAL_NULL(); \
if (!bson_empty(&(reply))) { \
RETVAL_BSON_T(reply); \
} \
} while (0)
/* Returns true if keyid is a UUID Binary value with an appropriate data length;
* otherwise, throws an exception and returns false. */
staticboolvalidate_keyid(bson_value_t*keyid)
{
if(keyid->value_type!=BSON_TYPE_BINARY){
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT,"Expected keyid to have Binary BSON type, %s given",php_phongo_bson_type_to_string(keyid->value_type));
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT,"Expected keyid to have UUID Binary subtype (%d), %d given",BSON_SUBTYPE_UUID,keyid->value.v_binary.subtype);
returnfalse;
}
/* php_phongo_binary_init already enforces the data length for Binary objects
* with UUID subtypes so we throw a different exception here. */
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE,"Expected keyid to have data length of %d bytes, %d given",PHONGO_BINARY_UUID_SIZE,keyid->value.v_binary.data_len);
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT,"Expected \"masterKey\" option to be array or object, %s given",PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(zmasterkey));
gotocleanup;
}
if(!provider){
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT,"The \"masterKey\" option should not be specified without \"provider\"");
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT,"Expected \"keyVaultClient\" option to be %s, %s given",ZSTR_VAL(php_phongo_manager_ce->name),PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(key_vault_client));
/* If the ClientEncryption object is being constructed directly, the
* "keyVaultClient" option must be explicitly provided. */
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT,"The \"keyVaultClient\" option is required when constructing a ClientEncryption object directly");
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT,"Expected \"kmsProviders\" option to be an array or object, %s given",PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(kms_providers));
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT,"Expected \"tlsOptions\" option to be an array or object, %s given",PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(tls_options));
phongo_throw_exception(PHONGO_ERROR_LOGIC,"Iterating over too many keyAltNames. Please file a bug report");
failed=true;
break;
}
if(Z_TYPE_P(keyaltname)!=IS_STRING){
if(string_key){
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT,"Expected keyAltName with index \"%s\" to be string, %s given",ZSTR_VAL(string_key),PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(keyaltname));
}else{
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT,"Expected keyAltName with index \"%lu\" to be string, %s given",num_key,PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(keyaltname));
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT,"Expected \"keyMaterial\" option to be %s, %s given",ZSTR_VAL(php_phongo_binary_ce->name),PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(keyMaterial));
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT,"Expected \"masterKey\" option to be array or object, %s given",PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(zmasterkey));
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT,"Expected \"precision\" range option to be a positive 32-bit integer, %"PRId64" given",precision);