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

fix(baggage): validate chars panic with 0x80 #5494

Merged
merged 5 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ This release drops the compatibility guarantee of [Go 1.19].
- Do not append `_total` if the counter already has that suffix for the Prometheus exproter in `go.opentelemetry.io/otel/exporter/prometheus`. (#4373)
- Fix resource detection data race in `go.opentelemetry.io/otel/sdk/resource`. (#4409)
- Use the first-seen instrument name during instrument name conflicts in `go.opentelemetry.io/otel/sdk/metric`. (#4428)
- Fix panic in baggage creation when a member contains 0x80 char in key or value. (#5494)
fabiobozzo marked this conversation as resolved.
Show resolved Hide resolved

### Deprecated

Expand Down
4 changes: 2 additions & 2 deletions baggage/baggage.go
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ func validateKey(s string) bool {
}

func validateKeyChar(c int32) bool {
return c >= 0 && c <= int32(utf8.RuneSelf) && safeKeyCharset[c]
return c >= 0 && c < int32(utf8.RuneSelf) && safeKeyCharset[c]
}

func validateValue(s string) bool {
Expand Down Expand Up @@ -850,7 +850,7 @@ var safeValueCharset = [utf8.RuneSelf]bool{
}

func validateValueChar(c int32) bool {
return c >= 0 && c <= int32(utf8.RuneSelf) && safeValueCharset[c]
return c >= 0 && c < int32(utf8.RuneSelf) && safeValueCharset[c]
}

// valueEscape escapes the string so it can be safely placed inside a baggage value,
Expand Down
4 changes: 2 additions & 2 deletions baggage/baggage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestValidateKeyChar(t *testing.T) {
'\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17',
'\x18', '\x19', '\x1A', '\x1B', '\x1C', '\x1D', '\x1E', '\x1F', ' ',
'(', ')', '<', '>', '@', ',', ';', ':', '\\', '"', '/', '[', ']', '?',
'=', '{', '}', '\x7F', 2 >> 20,
'=', '{', '}', '\x7F', 2 >> 20, '\x80',
}

for _, ch := range invalidKeyRune {
Expand All @@ -46,7 +46,7 @@ func TestValidateValueChar(t *testing.T) {
'\x08', '\x09', '\x0A', '\x0B', '\x0C', '\x0D', '\x0E', '\x0F',
'\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17',
'\x18', '\x19', '\x1A', '\x1B', '\x1C', '\x1D', '\x1E', '\x1F', ' ',
'"', ',', ';', '\\', '\x7F',
'"', ',', ';', '\\', '\x7F', '\x80',
}

for _, ch := range invalidValueRune {
Expand Down