Skip to content

Commit

Permalink
[gRPC]: Fix out-of-bounds access of string_view in GrpcClientCarrier …
Browse files Browse the repository at this point in the history
…in the example (#1619)
  • Loading branch information
Tradias authored Sep 19, 2022
1 parent 82a8115 commit ed9f583
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/grpc/tracer_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class GrpcClientCarrier : public opentelemetry::context::propagation::TextMapCar
opentelemetry::nostd::string_view value) noexcept override
{
std::cout << " Client ::: Adding " << key << " " << value << "\n";
context_->AddMetadata(key.data(), value.data());
context_->AddMetadata(std::string(key), std::string(value));
}

ClientContext *context_;
Expand All @@ -52,7 +52,7 @@ class GrpcServerCarrier : public opentelemetry::context::propagation::TextMapCar
virtual opentelemetry::nostd::string_view Get(
opentelemetry::nostd::string_view key) const noexcept override
{
auto it = context_->client_metadata().find(key.data());
auto it = context_->client_metadata().find({key.data(), key.size()});
if (it != context_->client_metadata().end())
{
return it->second.data();
Expand Down

1 comment on commit ed9f583

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'OpenTelemetry-cpp sdk Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: ed9f583 Previous: 82a8115 Ratio
BM_AlwaysOffSamplerConstruction 4.149319170371539 ns/iter 1.8856586521581713 ns/iter 2.20

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.