archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <>
To: "" 
	Julia Lawall <>
Subject: [PATCH] trace-cmd split: Fix off-by-one error when calculating record len
Date: Mon, 28 Jun 2021 22:26:09 -0400	[thread overview]
Message-ID: <20210628222609.01ea12ad@oasis.local.home> (raw)

From: "Steven Rostedt (VMware)" <>

When a record has 112 or fewer bytes (28 * 4) for size, it has a 4 byte
record that contains 5 bits for the size of the event divided by 4, and 27
bits for the time delta. (0, 29, 30 31 are special values for those 5

The split logic recreates the record header for each event it copies over
from the source trace file to the destination trace file. To decide the
header, it incorrectly checked for "less than" instead of "less than or
equal to" of size "28 * 4". This caused the copying of the event to add
the extended header.

The issue happened, because of the added 4 bytes, it ended up overwriting
the end of the page. The "\0" ended at the edge and was cut off.
(There should be a better check for this as well).

Fix the header check to use the compact header for 112 byte events.

Fixes: 87d2a344a ("trace-cmd: Add split feature")
Reported-by: Julia Lawall <>
Signed-off-by: Steven Rostedt (VMware) <>
 tracecmd/trace-split.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tracecmd/trace-split.c b/tracecmd/trace-split.c
index 233feb89..9b1a8d7a 100644
--- a/tracecmd/trace-split.c
+++ b/tracecmd/trace-split.c
@@ -106,7 +106,7 @@ static int write_record(struct tracecmd_input *handle,
 		return 0;
-	if (record->size && (record->size < 28 * 4))
+	if (record->size && (record->size <= 28 * 4))
 		len = record->size / 4;
 	time = (unsigned)diff;

                 reply	other threads:[~2021-06-29  2:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210628222609.01ea12ad@oasis.local.home \ \ \ \
    --subject='Re: [PATCH] trace-cmd split: Fix off-by-one error when calculating record len' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
on how to clone and mirror all data and code used for this inbox