Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gRPC]: Fix oob access of string_view in example #1619

Merged
merged 1 commit into from
Sep 19, 2022
Merged

[gRPC]: Fix oob access of string_view in example #1619

merged 1 commit into from
Sep 19, 2022

Conversation

Tradias
Copy link
Contributor

@Tradias Tradias commented Sep 18, 2022

The GrpcClient/ServerCarrier in the gRPC examples assume that the provided string_views are null-terminated,
which is not necessarily the case, e.g. when they are provided by the HttpTraceContext:

char trace_parent[kTraceParentSize];
trace_parent[0] = '0';
trace_parent[1] = '0';
trace_parent[2] = '-';
span_context.trace_id().ToLowerBase16(
nostd::span<char, 2 * TraceId::kSize>{&trace_parent[3], kTraceIdSize});
trace_parent[kTraceIdSize + 3] = '-';
span_context.span_id().ToLowerBase16(
nostd::span<char, 2 * SpanId::kSize>{&trace_parent[kTraceIdSize + 4], kSpanIdSize});
trace_parent[kTraceIdSize + kSpanIdSize + 4] = '-';
span_context.trace_flags().ToLowerBase16(
nostd::span<char, 2>{&trace_parent[kTraceIdSize + kSpanIdSize + 5], 2});
carrier.Set(kTraceParent, nostd::string_view(trace_parent, sizeof(trace_parent)));

@Tradias Tradias requested a review from a team September 18, 2022 11:37
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Sep 18, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: Tradias / name: Dennis (b8758ca)

@codecov
Copy link

codecov bot commented Sep 18, 2022

Codecov Report

Merging #1619 (b8758ca) into main (82a8115) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1619   +/-   ##
=======================================
  Coverage   85.24%   85.24%           
=======================================
  Files         156      156           
  Lines        4978     4978           
=======================================
  Hits         4243     4243           
  Misses        735      735           

Copy link
Member

@owent owent left a comment

Choose a reason for hiding this comment

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

LGTM

@lalitb lalitb merged commit ed9f583 into open-telemetry:main Sep 19, 2022
yxue pushed a commit to yxue/opentelemetry-cpp that referenced this pull request Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants