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 69e2603c48 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 31297dbb82)
This commit is contained in:
John Thacker 2021-04-05 09:03:36 -04:00
parent 13546c7a18
commit b20a77698d
1 changed files with 9 additions and 2 deletions

View File

@ -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;
}