aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Thacker <johnthacker@gmail.com>2021-04-05 09:03:36 -0400
committerJohn Thacker <johnthacker@gmail.com>2021-05-25 23:09:21 +0000
commitb20a77698d9cc967d727832a3c22efb3b09ddbbb (patch)
tree51a8a1db5502f1532ba5311b44aad395cb14a70c
parent13546c7a183b73e74ffc99bde19cb4b0f5f0f910 (diff)
ftype-protocol: Fix crash when comparing _ws.expert to literals
The ftype-protocol has two components to its value - a tvb, which is allowed to be be NULL (most notably in _ws.expert), and a string description. They can also be created from string literals, such as in display filters. It's possible to compare protocols with a NULL tvb with protocol terms created from literals, e.g. entering the display filter "_ws_expert < 1". Partially revert 69e2603c48d04a675785d9e7bad162ebb9a83b07 so that this doesn't crash, by assigning proto_string to the empty string instead of null when creating from a literal. Fixes #17316 (cherry picked from commit 31297dbb82da0b3adf5c257398638d9b4da94931)
-rw-r--r--epan/ftypes/ftype-protocol.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/epan/ftypes/ftype-protocol.c b/epan/ftypes/ftype-protocol.c
index 71ffae00c0..3c722ea455 100644
--- a/epan/ftypes/ftype-protocol.c
+++ b/epan/ftypes/ftype-protocol.c
@@ -67,9 +67,11 @@ val_from_string(fvalue_t *fv, const char *s, gchar **err_msg _U_)
/* And let us know that we need to free the tvbuff */
fv->tvb_is_private = TRUE;
- /* This "field" is a value, it has no protocol description. */
+ /* This "field" is a value, it has no protocol description, but
+ * we might compare it to a protocol with NULL tvb.
+ * (e.g., proto_expert) */
fv->value.protocol.tvb = new_tvb;
- fv->value.protocol.proto_string = NULL;
+ fv->value.protocol.proto_string = g_strdup("");
return TRUE;
}
@@ -98,6 +100,11 @@ val_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_,
/* And let us know that we need to free the tvbuff */
fv->tvb_is_private = TRUE;
fv->value.protocol.tvb = new_tvb;
+
+ /* This "field" is a value, it has no protocol description, but
+ * we might compare it to a protocol with NULL tvb.
+ * (e.g., proto_expert) */
+ fv->value.protocol.proto_string = g_strdup("");
return TRUE;
}