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
This commit is contained in:
John Thacker 2023-07-16 21:45:53 -04:00
parent e3bedc57ba
commit 6f6a8d9b66
1 changed files with 5 additions and 0 deletions

View File

@ -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: