http-urlencoded: Pass the correct string length to get_utf_8_string

Pass in the correct length of the percent decoded string, which
is not necessarily the same as the value calculated from the offsets.
Fix #18322. Fix #18325.
This commit is contained in:
John Thacker 2022-09-08 23:12:58 -04:00
parent 2c37027762
commit af0b20a969
1 changed files with 2 additions and 2 deletions

View File

@ -156,7 +156,7 @@ dissect_form_urlencoded(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi
* indicating that replacement characters had to be used,
* and that the string was not the expected encoding.
*/
key_decoded = get_utf_8_string(pinfo->pool, key, next_offset - offset);
key_decoded = get_utf_8_string(pinfo->pool, key, (int)strlen(key));
proto_tree_add_string(sub, hf_form_key, tvb, offset, next_offset - offset, key_decoded);
proto_item_append_text(sub, ": \"%s\"", format_text(pinfo->pool, key, strlen(key)));
@ -165,7 +165,7 @@ dissect_form_urlencoded(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi
next_offset = get_form_key_value(tvb, &value, offset, '&');
if (next_offset == -1)
break;
value_decoded = get_utf_8_string(pinfo->pool, value, next_offset - offset);
value_decoded = get_utf_8_string(pinfo->pool, value, (int)strlen(value));
proto_tree_add_string(sub, hf_form_value, tvb, offset, next_offset - offset, value_decoded);
proto_item_append_text(sub, " = \"%s\"", format_text(pinfo->pool, value, strlen(value)));