diff options
author | Craig Tiller <ctiller@google.com> | 2017-01-23 07:48:19 -0800 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2017-01-23 07:48:19 -0800 |
commit | c7342a01bb069fcff6df0e22f6c2a403010998a1 (patch) | |
tree | d938c40ce9d880c13be1e928c1e3bc5de65ca1b9 /src/core/lib/security/credentials/plugin | |
parent | a60b31d0a4f24ec061cc3dd9129f93a0319f1429 (diff) | |
parent | 5e01e2ac977655aa074faf7fde0a74298f5e4c55 (diff) |
Merge branch 'revert-8842-metadata_filter' of github.com:grpc/grpc into rollfwd
Diffstat (limited to 'src/core/lib/security/credentials/plugin')
-rw-r--r-- | src/core/lib/security/credentials/plugin/plugin_credentials.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.c b/src/core/lib/security/credentials/plugin/plugin_credentials.c index 7bc5dfb403..f90d7dce83 100644 --- a/src/core/lib/security/credentials/plugin/plugin_credentials.c +++ b/src/core/lib/security/credentials/plugin/plugin_credentials.c @@ -42,9 +42,7 @@ #include <grpc/support/sync.h> #include "src/core/lib/slice/slice_internal.h" -#include "src/core/lib/slice/slice_string_helpers.h" #include "src/core/lib/surface/api_trace.h" -#include "src/core/lib/surface/validate_metadata.h" typedef struct { void *user_data; @@ -65,9 +63,7 @@ static void plugin_md_request_metadata_ready(void *request, grpc_status_code status, const char *error_details) { /* called from application code */ - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INITIALIZER( - GRPC_EXEC_CTX_FLAG_IS_FINISHED | GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP, - NULL, NULL); + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_metadata_plugin_request *r = (grpc_metadata_plugin_request *)request; if (status != GRPC_STATUS_OK) { if (error_details != NULL) { @@ -81,14 +77,13 @@ static void plugin_md_request_metadata_ready(void *request, bool seen_illegal_header = false; grpc_credentials_md *md_array = NULL; for (i = 0; i < num_md; i++) { - if (!GRPC_LOG_IF_ERROR("validate_metadata_from_plugin", - grpc_validate_header_key_is_legal(md[i].key))) { + if (!grpc_header_key_is_legal(md[i].key, strlen(md[i].key))) { + gpr_log(GPR_ERROR, "Plugin added invalid metadata key: %s", md[i].key); seen_illegal_header = true; break; - } else if (!grpc_is_binary_header(md[i].key) && - !GRPC_LOG_IF_ERROR( - "validate_metadata_from_plugin", - grpc_validate_header_nonbin_value_is_legal(md[i].value))) { + } else if (!grpc_is_binary_header(md[i].key, strlen(md[i].key)) && + !grpc_header_nonbin_value_is_legal(md[i].value, + md[i].value_length)) { gpr_log(GPR_ERROR, "Plugin added invalid metadata value."); seen_illegal_header = true; break; @@ -100,8 +95,9 @@ static void plugin_md_request_metadata_ready(void *request, } else if (num_md > 0) { md_array = gpr_malloc(num_md * sizeof(grpc_credentials_md)); for (i = 0; i < num_md; i++) { - md_array[i].key = grpc_slice_ref_internal(md[i].key); - md_array[i].value = grpc_slice_ref_internal(md[i].value); + md_array[i].key = grpc_slice_from_copied_string(md[i].key); + md_array[i].value = + grpc_slice_from_copied_buffer(md[i].value, md[i].value_length); } r->cb(&exec_ctx, r->user_data, md_array, num_md, GRPC_CREDENTIALS_OK, NULL); |