decode_opentelemetry: guard NULL fqname and label name in compute_metric_hash#265
Merged
edsiper merged 2 commits intofluent:masterfrom May 4, 2026
Merged
Conversation
832b4cf to
fd32c59
Compare
…d compute_metric_hash decode_data_point_labels falls into its else branch for unrecognised AnyValue.value_case values (e.g. NOT_SET = 0) and passes NULL to append_new_metric_label_value, leaving label->name as NULL. Any encoder calling cfl_sds_len(label->name) -- including cmt_encode_text and cmt_encode_splunk_hec -- then crashes. Fix: store "" (empty string) in the unrecognised-value fallback, consistent with STRING_VALUE_STRINDEX. Also extend the early-return guard in compute_metric_hash to cover map->opts == NULL and map->opts->fqname == NULL (matching get_or_create_metric_metadata_context), and skip NULL label names in the hash loop, for defence in depth. Signed-off-by: Enoque Duarte <enoquefcd@gmail.com>
…Value Add otlp_null_label_histogram.bin -- a serialised ExportMetricsServiceRequest with one Histogram data point whose sole attribute has AnyValue.value_case = NOT_SET. The test opentelemetry_histogram_null_label_no_crash verifies the decoder returns CMT_DECODE_OPENTELEMETRY_SUCCESS rather than exiting with SIGSEGV. Signed-off-by: Enoque Duarte <enoquefcd@gmail.com>
fd32c59 to
da4b9fa
Compare
Member
|
thank you |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
compute_metric_hashdereferencesmap->opts->fqnameandlabel_value->namewithout NULL checks while its peerget_or_create_metric_metadata_context, called immediately after from the same caller, already guardsmap->optsandmap->opts->fqname. The unguarded path is reachable from real OTLP/HTTP histogram payloads —cfl_sds_len(NULL)segfaults the worker.Reported and reproduced via fluent/fluent-bit#11764 with Quarkus 3.32.x clients pushing histograms over OTLP/HTTP. Stack trace:
Root cause
decode_data_point_labelsfalls into itselsebranch for unrecognisedAnyValue.value_casevalues (e.g.NOT_SET = 0) and passesNULLtoappend_new_metric_label_value.create_label(NULL, …)leaveslabel->nameas NULL, which crashes any encoder callingcfl_sds_len(label->name)— not onlycompute_metric_hashbut alsocmt_encode_textandcmt_encode_splunk_hec.Changes
decode_data_point_labels: store""(empty string) in the unrecognised-value fallback, consistent withSTRING_VALUE_STRINDEX. Prevents NULL from enteringmetric->labels.compute_metric_hash: extend the early-return guard to covermap->opts == NULL || map->opts->fqname == NULL(matchingget_or_create_metric_metadata_context), and skip NULL label names in the hash loop — defence in depth.Regression test
tests/data/otlp_null_label_histogram.bin— a serialisedExportMetricsServiceRequestwith one Histogram data point whose sole attribute hasAnyValue.value_case = NOT_SET. Without this fix the test exits SIGSEGV (signal 11); with it,CMT_DECODE_OPENTELEMETRY_SUCCESS.ctest --test-dir build -R cmt-test-opentelemetry --output-on-failure # or ./build/tests/cmt-test-opentelemetry opentelemetry_histogram_null_label_no_crash