Skip to content

Commit a57063f

Browse files
authored
fix: buffer overrun in the gRPC sample project (open-telemetry#3304)
Building the sample on Windows, the gRPC sample server/client app fails to function correctly. The propagated trace context is corrupted, containing garbage characters after the trace parent string. The string buffer from gRPC cannot be safely treated as a null-terminated C-string. To ensure safe copying, we must use its length property instead.
1 parent d09bfba commit a57063f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

examples/grpc/tracer_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class GrpcServerCarrier : public opentelemetry::context::propagation::TextMapCar
5959
auto it = context_->client_metadata().find({key.data(), key.size()});
6060
if (it != context_->client_metadata().end())
6161
{
62-
return it->second.data();
62+
return opentelemetry::nostd::string_view(it->second.data(), it->second.size());
6363
}
6464
return "";
6565
}

0 commit comments

Comments
 (0)