From 1cf251a5784e84171659b95293ed1f9d92f2b800 Mon Sep 17 00:00:00 2001 From: Srinivasan J Date: Sun, 3 Dec 2023 08:50:25 +0530 Subject: [PATCH] decode: opentelemetry: Fix a crash in fluent-bit This patch fixes a crash in fluent-bit when ctr_decode_opentelemetry_create() tries to access the span status and when that span status is not present. the patch has been tested with opentelemetry-cpp-1.12.0/example_otlp_http http://localhost:4318/v1/traces DEBUG=yes bin and fluent-bit 2.2.0 Signed-off-by: Srinivasan J --- src/ctr_decode_opentelemetry.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ctr_decode_opentelemetry.c b/src/ctr_decode_opentelemetry.c index 139ae2c..ba9f2eb 100644 --- a/src/ctr_decode_opentelemetry.c +++ b/src/ctr_decode_opentelemetry.c @@ -571,7 +571,9 @@ int ctr_decode_opentelemetry_create(struct ctrace **out_ctr, ctr_span_kind_set(span, otel_span->kind); ctr_span_start_ts(ctr, span, otel_span->start_time_unix_nano); ctr_span_end_ts(ctr, span, otel_span->end_time_unix_nano); - ctr_span_set_status(span, otel_span->status->code, otel_span->status->message); + if (otel_span->status) { + ctr_span_set_status(span, otel_span->status->code, otel_span->status->message); + } ctr_span_set_attributes(span, otel_span->n_attributes, otel_span->attributes); ctr_span_set_events(span, otel_span->n_events, otel_span->events); ctr_span_set_dropped_attributes_count(span, otel_span->dropped_attributes_count);