Commit 1b62bd8
committed
src.ctf.fs: be less strict when encountering trailing byte at the end of packetized CTF 1.8 metadata
A client has some traces with CTF 1.8 packetized metadata that has an
unexpected 0x0A (\n) byte at the end. The metadata file consists of a
sequence of several well-formed metadata packets, followed by one 0x0A
byte. It is not known where this byte comes from, it could have been
inserted as the result of some post-processing of the metadata files.
While not a valid metadata stream, Babeltrace 2.0 accepted it without
complaining. The code in 2.0 looked like:
readlen = fread(&header, sizeof(header), 1, in_fp);
... where `header` represents a metadata packet header. Because the
number of remaining bytes to read was less than the size of `header`,
`fread` would return 0. Babeltrace would conclude that it had reached
the end of the file and would exit the loop, without ever noticing this
extra byte.
In 2.1, Babeltrace is more strict, and emits this error:
CAUSED BY ['source.ctf.fs'] (/home/smarchi/src/babeltrace/src/plugins/ctf/common/src/metadata/tsdl/metadata-stream-decoder.cpp:314)
Failed to decode metadata stream section: data-ptr=0x79d1d9fec900, data-len-bytes=4097
CAUSED BY ['source.ctf.fs'] (/home/smarchi/src/babeltrace/src/plugins/ctf/common/src/metadata/tsdl/metadata-stream-decoder.cpp:274)
Failed to read a metadata stream packet: offset-bytes=4096, pkt-idx=1
CAUSED BY ['source.ctf.fs'] (/home/smarchi/src/babeltrace/src/plugins/ctf/common/src/metadata/tsdl/metadata-stream-decoder.cpp:244)
Remaining buffer isn't large enough to hold a packet header.
Even though this isn't technically a valid metadata stream, and we don't
know where this mysterious 0x0A byte comes from, the fact that
Babeltrace 2.0 accepted it and 2.1 rejects it can be a problem for
real-world users, if traces like this are in the wild.
Since this extra byte doesn't really prevent Babeltrace from reading the
trace as it did before, I propose to change the error to a warning.
Add a test for this, which consists of a copy of the `2packets`, to
which I added a trailing 0x0A byte to the metadata file.
The result looks like this:
05-14 14:47:52.527 107232 107232 W PLUGIN/CTF/META/DECODER _textFromPacketizedMetadata@/home/smarchi/src/babeltrace/src/plugins/ctf/common/src/metadata/tsdl/metadata-stream-decoder.cpp:244 Remaining buffer isn't large enough to hold a packet header.
Note that this warning appears three times when relying on the CLI's
autodisovery feature, because the metadata is parsed three times in this
case:
- once during the "support info" query
- once during the "get supported MIP versions" method call
- once when instantiating the component
Change-Id: Ibaaacd52e8993e0b126691d3591dee67fb94b3a0
Signed-off-by: Simon Marchi <[email protected]>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/14630
Tested-by: jenkins <[email protected]>
Reviewed-by: Philippe Proulx <[email protected]>
(cherry picked from commit b83661e)
Reviewed-on: https://review.lttng.org/c/babeltrace/+/148691 parent 0325525 commit 1b62bd8
File tree
6 files changed
+14
-4
lines changed- src/plugins/ctf/common/src/metadata/tsdl
- tests
- cli
- data/ctf-traces/1/succeed/meta-trailing-byte
- index
- plugins/src.ctf.fs/succeed
6 files changed
+14
-4
lines changedLines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
244 | | - | |
245 | | - | |
| 244 | + | |
| 245 | + | |
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
Binary file not shown.
Binary file not shown.
Binary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
201 | 210 | | |
202 | 211 | | |
203 | 212 | | |
| |||
211 | 220 | | |
212 | 221 | | |
213 | 222 | | |
| 223 | + | |
214 | 224 | | |
215 | 225 | | |
216 | 226 | | |
| |||
0 commit comments