epan: Always set our proto_item_fill_label label.

Make sure label_str is valid, and print a warning if it's NULL. Try to
fix

```
/builds/wireshark/wireshark/epan/dissectors/packet-diameter.c: 1174 in integer32_avp()
1168     	gint length = tvb_reported_length(tvb);
1169     	if (length == 4) {
1170     		if (c->tree) {
1171     			pi= proto_tree_add_item(c->tree, a->hf_value, tvb, 0, length, ENC_BIG_ENDIAN);
1172     			label = (char *)wmem_alloc(wmem_packet_scope(), ITEM_LABEL_LENGTH+1);
1173     			proto_item_fill_label(PITEM_FINFO(pi), label);
>>>     CID 1499506:  Memory - illegal accesses  (STRING_NULL)
>>>     Passing unterminated string "label" to "strstr", which expects a null-terminated string.
1174     			label = strstr(label,": ")+2;
1175     		}
1176     	}
1177     	else {
1178     		pi = proto_tree_add_bytes_format(c->tree, hf_diameter_avp_data_wrong_length,
1179     						 tvb, 0, length, NULL,

```
This commit is contained in:
Gerald Combs 2022-02-15 12:32:25 -08:00 committed by A Wireshark GitLab Utility
parent 4c90ca7ad2
commit fbf403de00
1 changed files with 7 additions and 3 deletions

View File

@ -9039,10 +9039,14 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
char *addr_str;
char *tmp;
if (!label_str) {
ws_warning("NULL label_str passed to proto_item_fill_label.");
return;
}
label_str[0]= '\0';
if (!fi) {
if (label_str)
label_str[0]= '\0';
/* XXX: Check validity of hfinfo->type */
return;
}