forked from osmocom/wireshark
u3v: clean up the heuristic check
check for the minimum lenght before dereferencing data add a NULL check for usb_conv_info Change-Id: I91014d5929f57cc9eed2bfc7adef9f89541ece45 Reviewed-on: https://code.wireshark.org/review/14221 Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
This commit is contained in:
parent
ea6d1457b2
commit
c18527619e
|
@ -1882,27 +1882,28 @@ static gboolean
|
||||||
dissect_u3v_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
|
dissect_u3v_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
|
||||||
{
|
{
|
||||||
guint32 prefix;
|
guint32 prefix;
|
||||||
usb_conv_info_t *usb_conv_info =NULL;
|
usb_conv_info_t *usb_conv_info;
|
||||||
u3v_conv_info_t *u3v_conv_info =NULL;
|
u3v_conv_info_t *u3v_conv_info;
|
||||||
|
|
||||||
|
/* all control and meta data packets of U3V contain at least the prefix */
|
||||||
|
if (tvb_reported_length(tvb) < 4)
|
||||||
|
return FALSE;
|
||||||
|
prefix = tvb_get_letohl(tvb, 0);
|
||||||
|
|
||||||
/* check if stream endpoint has been already set up for this conversation */
|
/* check if stream endpoint has been already set up for this conversation */
|
||||||
usb_conv_info = (usb_conv_info_t *)data;
|
usb_conv_info = (usb_conv_info_t *)data;
|
||||||
|
if (!usb_conv_info)
|
||||||
|
return FALSE;
|
||||||
u3v_conv_info = (u3v_conv_info_t *)usb_conv_info->class_data;
|
u3v_conv_info = (u3v_conv_info_t *)usb_conv_info->class_data;
|
||||||
|
|
||||||
|
|
||||||
/* all control and meta data packets of U3V contain at least the prefix */
|
|
||||||
if (tvb_reported_length(tvb) < 4) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* either right prefix or the endpoint of the current transfer has been recognized as stream endpoint already */
|
/* either right prefix or the endpoint of the current transfer has been recognized as stream endpoint already */
|
||||||
prefix = tvb_get_letohl(tvb, 0);
|
|
||||||
if ((U3V_STREAM_LEADER_PREFIX == prefix) || (U3V_STREAM_TRAILER_PREFIX == prefix) ||
|
if ((U3V_STREAM_LEADER_PREFIX == prefix) || (U3V_STREAM_TRAILER_PREFIX == prefix) ||
|
||||||
(U3V_CONTROL_PREFIX == prefix) || (U3V_EVENT_PREFIX == prefix) ||
|
(U3V_CONTROL_PREFIX == prefix) || (U3V_EVENT_PREFIX == prefix) ||
|
||||||
( u3v_conv_info && (usb_conv_info->endpoint == u3v_conv_info->ep_stream))) {
|
( u3v_conv_info && (usb_conv_info->endpoint == u3v_conv_info->ep_stream))) {
|
||||||
dissect_u3v(tvb, pinfo, tree, data);
|
dissect_u3v(tvb, pinfo, tree, data);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue