aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2022-10-10 09:18:22 -0700
committerGerald Combs <gerald@wireshark.org>2022-10-11 16:59:32 +0000
commitf3f1556d456a7a3d3a70c7c4f05cdd02f01463e6 (patch)
tree5bbcbc7f9664fbe5ce94c74b63ccbd74b6c0fcc7 /ui/qt
parenta19834b98cda6d31bc31534b8cd497d055645439 (diff)
Qt: Properly truncate our FieldInformation strings.
As the Qt6 QString::QString(const QByteArray &ba) documenation says: "Note: any null ('\0') bytes in the byte array will be included in this string, converted to Unicode null characters (U+0000). This behavior is different from Qt 5.x." Make sure FieldInformation::toString() truncates its display label byte array before converting it to a QString. Fixes #18428
Diffstat (limited to 'ui/qt')
-rw-r--r--ui/qt/utils/field_information.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/ui/qt/utils/field_information.cpp b/ui/qt/utils/field_information.cpp
index 532fed167a..946731b58e 100644
--- a/ui/qt/utils/field_information.cpp
+++ b/ui/qt/utils/field_information.cpp
@@ -141,7 +141,8 @@ QString FieldInformation::toString()
QByteArray display_label;
display_label.resize(80); // Arbitrary.
- proto_item_fill_display_label(fi_, display_label.data(), static_cast<int>(display_label.size()));
+ int label_len = proto_item_fill_display_label(fi_, display_label.data(), static_cast<int>(display_label.size())-1);
+ display_label.resize(label_len);
if (display_label.isEmpty()) {
return "[no value for field]";