Skip to content

Commit

Permalink
[call_creds_util] Add debug checks for metadata accesses (grpc#37822)
Browse files Browse the repository at this point in the history
Fix grpc#37701

<!--

If you know who should review your pull request, please assign it to that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the appropriate
lang label.

-->

Closes grpc#37822

COPYBARA_INTEGRATE_REVIEW=grpc#37822 from yijiem:debug-check-metadata 67df0da
PiperOrigin-RevId: 680734161
  • Loading branch information
yijiem authored and copybara-github committed Sep 30, 2024
1 parent daa7938 commit 80b57c9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/core/lib/security/credentials/call_creds_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <string.h>

#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
Expand All @@ -42,6 +43,7 @@ struct ServiceUrlAndMethod {
ServiceUrlAndMethod MakeServiceUrlAndMethod(
const ClientMetadataHandle& initial_metadata,
const grpc_call_credentials::GetRequestMetadataArgs* args) {
DCHECK(initial_metadata->get_pointer(HttpPathMetadata()) != nullptr);
auto service =
initial_metadata->get_pointer(HttpPathMetadata())->as_string_view();
auto last_slash = service.find_last_of('/');
Expand All @@ -56,6 +58,7 @@ ServiceUrlAndMethod MakeServiceUrlAndMethod(
method_name = service.substr(last_slash + 1);
service = service.substr(0, last_slash);
}
DCHECK(initial_metadata->get_pointer(HttpAuthorityMetadata()) != nullptr);
auto host_and_port =
initial_metadata->get_pointer(HttpAuthorityMetadata())->as_string_view();
absl::string_view url_scheme = args->security_connector->url_scheme();
Expand Down

0 comments on commit 80b57c9

Please sign in to comment.