Changing a few variable names and adding few safety conditions

pull/11884/head
Yash Tibrewal 7 years ago
parent c62ce80b80
commit d0c1e50ea9
  1. 2
      src/core/ext/filters/client_channel/http_proxy.c
  2. 6
      test/core/end2end/fixtures/h2_http_proxy.c
  3. 15
      test/core/end2end/fixtures/http_proxy_fixture.c

@ -67,7 +67,7 @@ static char* get_http_proxy_server(grpc_exec_ctx* exec_ctx, char** user_cred) {
/* User cred found */
*user_cred = authority_strs[0];
proxy_name = authority_strs[1];
gpr_log(GPR_INFO, "userinfo found in proxy URI");
gpr_log(GPR_DEBUG, "userinfo found in proxy URI");
} else {
/* Bad authority */
for (size_t i = 0; i < authority_nstrs; i++) {

@ -68,13 +68,13 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f,
char *proxy_uri;
/* If testing for proxy auth, add credentials to proxy uri */
const grpc_arg *proxy_auth =
const grpc_arg *proxy_auth_arg =
grpc_channel_args_find(client_args, GRPC_ARG_HTTP_PROXY_AUTH_CREDS);
if (proxy_auth == NULL) {
if (proxy_auth_arg == NULL || proxy_auth_arg->type != GRPC_ARG_STRING) {
gpr_asprintf(&proxy_uri, "http://%s",
grpc_end2end_http_proxy_get_proxy_name(ffd->proxy));
} else {
gpr_asprintf(&proxy_uri, "http://%s@%s", proxy_auth->value.string,
gpr_asprintf(&proxy_uri, "http://%s@%s", proxy_auth_arg->value.string,
grpc_end2end_http_proxy_get_proxy_name(ffd->proxy));
}
gpr_setenv("http_proxy", proxy_uri);

@ -315,7 +315,8 @@ static void on_server_connect_done(grpc_exec_ctx* exec_ctx, void* arg,
static bool proxy_auth_header_matches(grpc_exec_ctx* exec_ctx,
char* proxy_auth_header_val,
char* expected_cred) {
GPR_ASSERT(proxy_auth_header_val != NULL && expected_cred != NULL);
GPR_ASSERT(proxy_auth_header_val != NULL);
GPR_ASSERT(expected_cred != NULL);
if (strncmp(proxy_auth_header_val, "Basic ", 6) != 0) {
return false;
}
@ -377,19 +378,19 @@ static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg,
return;
}
// If proxy auth is being used, check if the header is present and as expected
const grpc_arg* proxy_auth = grpc_channel_args_find(
const grpc_arg* proxy_auth_arg = grpc_channel_args_find(
conn->proxy->channel_args, GRPC_ARG_HTTP_PROXY_AUTH_CREDS);
if (proxy_auth != NULL) {
bool auth_header_found = false;
if (proxy_auth_arg != NULL && proxy_auth_arg->type == GRPC_ARG_STRING) {
bool client_authenticated = false;
for (size_t i = 0; i < conn->http_request.hdr_count; i++) {
if (strcmp(conn->http_request.hdrs[i].key, "Proxy-Authorization") == 0) {
auth_header_found = proxy_auth_header_matches(
client_authenticated = proxy_auth_header_matches(
exec_ctx, conn->http_request.hdrs[i].value,
proxy_auth->value.string);
proxy_auth_arg->value.string);
break;
}
}
if (!auth_header_found) {
if (!client_authenticated) {
const char* msg = "HTTP Connect could not verify authentication";
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(msg);
proxy_connection_failed(exec_ctx, conn, true /* is_client */,

Loading…
Cancel
Save