aboutsummaryrefslogtreecommitdiffstats
path: root/epan/proto.c
diff options
context:
space:
mode:
authorJoão Valverde <j@v6e.pt>2022-10-26 15:13:22 +0100
committerJoão Valverde <j@v6e.pt>2022-10-26 16:23:55 +0100
commit76a6e2a2bf4d11a1934220569dc50a9a69f16baf (patch)
tree02925d4e7785798c79e095c2860a4004d8cdd423 /epan/proto.c
parentc1cede8d7cb39a80eceb3bc87af0fc4288d50b36 (diff)
ftypes: Do not sanitize strings for UTF-8 errors
The ftype itself is encoding agnostic. In the case of literal display filter strings it is possible and legal to contain invalid UTF-8. Maybe it shouldn't be but that requires a user-friendly diagnostic message, not silently sanitizing the string as is done currently (only a debug message is printed in that case). Do the debug checks in proto_tree_set_string() instead. That still detects dissector code that might need fixing, which was the purpose for this check. Improve documentation and add admonition for proto_tree_add_string(). Ping #18521.
Diffstat (limited to 'epan/proto.c')
-rw-r--r--epan/proto.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/epan/proto.c b/epan/proto.c
index 649e3a40ce..3a751258e2 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -5010,6 +5010,8 @@ proto_tree_add_string(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
pi = proto_tree_add_pi(tree, hfinfo, tvb, start, &length);
DISSECTOR_ASSERT(length >= 0);
+
+ WS_UTF_8_CHECK(value, -1);
proto_tree_set_string(PNODE_FINFO(pi), value);
return pi;
@@ -5059,7 +5061,6 @@ static void
proto_tree_set_string(field_info *fi, const char* value)
{
if (value) {
- /* String must be valid UTF-8. It is sanitized otherwise (if enabled at compile time). */
fvalue_set_string(&fi->value, value);
} else {
/*