Skip to content

Commit

Permalink
Fix: liblttng-ctl: erroneous flat size computation
Browse files Browse the repository at this point in the history
compute_flattened_size() erroneously computes (over-estimates) the size
of the allocation required to hold the flat array of struct lttng_event
returned to the user by lttng_list_{events, syscalls, tracepoints}.

Signed-off-by: Jérémie Galarneau <[email protected]>
Change-Id: I0a80ef0fa66428b7df34303804a024e80b635c69
  • Loading branch information
jgalar committed Mar 8, 2022
1 parent 030ea32 commit fc33156
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/common/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1488,6 +1488,9 @@ static enum lttng_error_code compute_flattened_size(
/* The basic struct lttng_event */
storage_req = event_count * sizeof(struct lttng_event);

/* The struct·lttng_event_extended */
storage_req += event_count * sizeof(struct lttng_event_extended);

for (i = 0; i < event_count; i++) {
int probe_storage_req = 0;
const struct event_list_element *element = (const struct event_list_element *)
Expand All @@ -1508,10 +1511,6 @@ static enum lttng_error_code compute_flattened_size(
probe_storage_req = ret;
}

/* The struct·lttng_event_extended */
storage_req += event_count *
sizeof(struct lttng_event_extended);

if (element->filter_expression) {
storage_req += strlen(element->filter_expression) + 1;
}
Expand Down

0 comments on commit fc33156

Please sign in to comment.