802.11: Remove artificial string truncation

The wmem_strbuf_new_label() creates a new buffer with a length limit
in octets. With multibyte strings this is likely to generate invalid
UTF-8 errors.

Remove the artificial limit on the value size. The
function proto_tree_add_string() sets the value, and truncating
that to an arbitrary limit is not really correct.

The display label will be truncated to a preset length by the UI.
This mechanism uses ws_label_strcpy() and is designed to avoid
the invalid truncation.

While here use wmem_strbuf_get_str() instead of wmem_strbuf_finalize().

Accepted best practice is to let the scope free the memory.
Removing the finalize call avoids an unnecessary realloc.

Fixes #18653.
This commit is contained in:
João Valverde 2022-11-25 18:06:57 +00:00
parent ade32a12f2
commit 27ea011dd3
1 changed files with 2 additions and 2 deletions

View File

@ -15199,7 +15199,7 @@ dissect_he_feedback_matrix(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo,
int ri, ci;
int start_bit_offset = bit_offset;
int start_offset = offset;
wmem_strbuf_t *angles = wmem_strbuf_new_label(pinfo->pool);
wmem_strbuf_t *angles = wmem_strbuf_new(pinfo->pool, NULL);
if (nc == nr) /* If they are the same, reduce Nc by one */
nc -= 1;
@ -15224,7 +15224,7 @@ dissect_he_feedback_matrix(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo,
/* Update this */
proto_tree_add_string(tree, hf, tvb, offset,
((start_bit_offset + 7) / 8) - start_offset,
wmem_strbuf_finalize(angles));
wmem_strbuf_get_str(angles));
return bit_offset;
}