Skip to content

Commit

Permalink
out_opentelemetry: Prevent null dereference on memcpy (CID 507910)
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 committed Aug 30, 2024
1 parent d873502 commit e5c021c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions plugins/out_opentelemetry/opentelemetry_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,15 @@ Opentelemetry__Proto__Common__V1__AnyValue *msgpack_bin_to_otlp_any_value(struct
result->bytes_value.len = o->via.bin.size;
result->bytes_value.data = flb_malloc(o->via.bin.size);

if (result->bytes_value.data == NULL) {
if (result->bytes_value.data) {
memcpy(result->bytes_value.data, o->via.bin.ptr, o->via.bin.size);
}
else {
otlp_any_value_destroy(result);

result = NULL;
}

memcpy(result->bytes_value.data, o->via.bin.ptr, o->via.bin.size);
}

return result;
Expand Down

0 comments on commit e5c021c

Please sign in to comment.