Skip to content

Commit ed9f583

Browse files
authored
[gRPC]: Fix out-of-bounds access of string_view in GrpcClientCarrier in the example (#1619)
1 parent 82a8115 commit ed9f583

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

examples/grpc/tracer_common.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class GrpcClientCarrier : public opentelemetry::context::propagation::TextMapCar
3838
opentelemetry::nostd::string_view value) noexcept override
3939
{
4040
std::cout << " Client ::: Adding " << key << " " << value << "\n";
41-
context_->AddMetadata(key.data(), value.data());
41+
context_->AddMetadata(std::string(key), std::string(value));
4242
}
4343

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

0 commit comments

Comments
 (0)