Skip to content

Commit

Permalink
Terminate strings (comm names) on null terminator
Browse files Browse the repository at this point in the history
When a field of a certain size is parsed as string stop
if a null terminator is encountered.

Bug 579627

Change-Id: I57505b0cdb8ae4eab6fd791535de63fc58765cf9
Signed-off-by: Fabrizio Iannetti <fabrizio.iannetti@gmail.com>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass.incubator/org.eclipse.tracecompass.incubator/+/192600
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
  • Loading branch information
fabrizioiannetti authored and MatthewKhouzam committed Apr 19, 2022
1 parent e4e6768 commit 13b2bbc
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ private Object getPrimitiveDataValue(BinaryFTraceFormatField formatField, byte[]
}

private static String readStringField(byte[] fieldData) {
for (int i = 0; i < fieldData.length; i++) {
if (fieldData[i] == 0) {
return new String(fieldData, 0, i);
}
}
return new String(fieldData);
}

Expand Down

0 comments on commit 13b2bbc

Please sign in to comment.