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

out_opentelemetry: added missing result checks and fixed leaks (CID 514593) #9609

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Changes from all 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
25 changes: 24 additions & 1 deletion plugins/out_opentelemetry/opentelemetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ int opentelemetry_post(struct opentelemetry_context *ctx,
const char *compression_algorithm;
uint32_t wire_message_length;
size_t grpc_body_length;
cfl_sds_t sds_result;
cfl_sds_t grpc_body;
struct flb_http_response *response;
struct flb_http_request *request;
Expand Down Expand Up @@ -261,19 +262,41 @@ int opentelemetry_post(struct opentelemetry_context *ctx,
grpc_body = cfl_sds_create_size(body_len + 5);

if (grpc_body == NULL) {
flb_http_client_request_destroy(request, FLB_TRUE);

return FLB_RETRY;
}

wire_message_length = (uint32_t) body_len;

cfl_sds_cat(grpc_body, "\x00----", 5);

if (sds_result == NULL) {
flb_http_client_request_destroy(request, FLB_TRUE);

cfl_sds_destroy(grpc_body);

return FLB_RETRY;
}

grpc_body = sds_result;

((uint8_t *) grpc_body)[1] = (wire_message_length & 0xFF000000) >> 24;
((uint8_t *) grpc_body)[2] = (wire_message_length & 0x00FF0000) >> 16;
((uint8_t *) grpc_body)[3] = (wire_message_length & 0x0000FF00) >> 8;
((uint8_t *) grpc_body)[4] = (wire_message_length & 0x000000FF) >> 0;

cfl_sds_cat(grpc_body, body, body_len);
sds_result = cfl_sds_cat(grpc_body, body, body_len);

if (sds_result == NULL) {
flb_http_client_request_destroy(request, FLB_TRUE);

cfl_sds_destroy(grpc_body);

return FLB_RETRY;
}

grpc_body = sds_result;

grpc_body_length = cfl_sds_len(grpc_body);

Expand Down
Loading