From 6f6a8d9b661b3440635526949361745e1c9b8817 Mon Sep 17 00:00:00 2001 From: John Thacker Date: Sun, 16 Jul 2023 21:45:53 -0400 Subject: [PATCH] epan: Fix crash on columns with many long string fields ws_label_strcpy, like strlcpy, returns the number of bytes it would have written in the case of overflow. proto_item_fill_display_label needs to return the actual number of bytes copied (which is what protoo_strlcpy does). Fix #19212 --- epan/proto.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/epan/proto.c b/epan/proto.c index 2dd8b63a7a..5c849748ba 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -6727,6 +6727,11 @@ proto_item_fill_display_label(field_info *finfo, gchar *display_label_str, const case FT_STRINGZTRUNC: str = fvalue_get_string(finfo->value); label_len = (int)ws_label_strcpy(display_label_str, label_str_size, 0, str, label_strcat_flags(hfinfo)); + if (label_len >= label_str_size) { + /* Truncation occured. Get the real length + * copied (not including '\0') */ + label_len = label_str_size ? label_str_size - 1 : 0; + } break; default: