trace-cmd: Fix trace-cmd convert to handle offset update
PATCH 1/1 trace-cmd: Fix trace-cmd convert to handle offset update
From: "Steven Rostedt (Google)" <[email protected]>
With changing the cpu_data[]->file_offset to be unique per CPU, the convert code had a path that was still relying on it being zero. Specifically, when read_zpage is false. This would decompress the data into a temp file, and the offset would be from that temp file. Thus, using the unique file_offset would cause it to index farther than the size of the file and crash. Instead, subtract the cpu_data[].file_offset from the offset used in the temp file.
Fixes add83e0c8b51 ("trace-cmd library: Fix tracecmd_read_at()")
Signed-off-by Steven Rostedt (Google) <[email protected]>
--- lib/trace-cmd/trace-input.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
lib/trace-cmd/trace-input.c +3 -2
@@ -1442,9 +1442,10 @@ static void *allocate_page_map(struct tracecmd_input *handle, map_size -= map_offset + map_size - (cpu_data->file_offset + cpu_data->file_size); -if (cpu_data->compress.fd >=0 ) +if (cpu_data->compress.fd >=0 ) { + map_offset -= cpu_data->file_offset; fd = cpu_data->compress.fd; -else + }else fd = handle->fd; again: page_map->size = map_size;
Signature · 1 line
2.35.1