diff mbox series

[v4,23/23] trace-cmd: Read at least 8 bytes trace-id option

Message ID 20210325064055.539554-24-tz.stoyanov@gmail.com (mailing list archive)
State Accepted
Headers show
Series TSC trace clock to nanosecond conversion | expand

Commit Message

Tzvetomir Stoyanov (VMware) March 25, 2021, 6:40 a.m. UTC
When reading the trace-id option from trace.dat file, check if the size
is at least 8 bytes. If the size is greater, use the first 8 bytes only
and ignore the rest. That way we can safely extend this option in the
future, without breaking the legacy logic.

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 lib/trace-cmd/trace-input.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Steven Rostedt March 26, 2021, 9:18 p.m. UTC | #1
On Thu, 25 Mar 2021 08:40:55 +0200
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> wrote:

> When reading the trace-id option from trace.dat file, check if the size
> is at least 8 bytes. If the size is greater, use the first 8 bytes only
> and ignore the rest. That way we can safely extend this option in the
> future, without breaking the legacy logic.
> 
> Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
> ---
>  lib/trace-cmd/trace-input.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
> index 513f6cc3..c0b47345 100644
> --- a/lib/trace-cmd/trace-input.c
> +++ b/lib/trace-cmd/trace-input.c
> @@ -2703,7 +2703,7 @@ static int handle_options(struct tracecmd_input *handle)
>  				trace_pid_map_load(handle, buf);
>  			break;
>  		case TRACECMD_OPTION_TRACEID:
> -			if (size != 8)
> +			if (size < 8)
>  				break;
>  			handle->trace_id = tep_read_number(handle->pevent,
>  							   buf, 8);

This looks like it is unrelated to this patch set. I'm moving it to the
beginning, and will likely even add it to the v2.9 stable branch.

-- Steve
diff mbox series

Patch

diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index 513f6cc3..c0b47345 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -2703,7 +2703,7 @@  static int handle_options(struct tracecmd_input *handle)
 				trace_pid_map_load(handle, buf);
 			break;
 		case TRACECMD_OPTION_TRACEID:
-			if (size != 8)
+			if (size < 8)
 				break;
 			handle->trace_id = tep_read_number(handle->pevent,
 							   buf, 8);