forked from osmocom/wireshark
Make RX a new style dissector: return 0 if there isn't at least 28 bytes of message or if it receives an unknown Type. Add a check of tvb length to README.developer's cut-n-paste dissector code.
svn path=/trunk/; revision=21300
This commit is contained in:
parent
98cc46f2a4
commit
a5f4e7b85a
|
@ -733,6 +733,9 @@ dissect_PROTOABBREV(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
* if someone analyzed that web server's traffic in Wireshark, would result
|
||||
* in Wireshark handing an HTTP packet to your dissector). For example:
|
||||
*/
|
||||
/* Check that there's enough data */
|
||||
if (tvb_length(tvb) < /* your protocol's smallest packet size */)
|
||||
return 0;
|
||||
|
||||
/* Get some values from the packet header, probably using tvb_get_*() */
|
||||
if ( /* these values are not possible in PROTONAME */ )
|
||||
|
|
|
@ -452,7 +452,7 @@ dissect_rx_flags(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *parent_tree,
|
|||
return offset;
|
||||
}
|
||||
|
||||
static void
|
||||
static int
|
||||
dissect_rx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
|
||||
{
|
||||
proto_tree *tree;
|
||||
|
@ -463,6 +463,15 @@ dissect_rx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
|
|||
guint32 seq, callnumber;
|
||||
guint16 serviceid;
|
||||
|
||||
/* Ensure we have enough data */
|
||||
if (tvb_length(tvb) < 28)
|
||||
return 0;
|
||||
|
||||
/* Make sure it's a known type */
|
||||
type = tvb_get_guint8(tvb, 20);
|
||||
if (type == 0 || type == 10 || type == 11 || type == 12 || type > 13)
|
||||
return 0;
|
||||
|
||||
if (check_col(pinfo->cinfo, COL_PROTOCOL))
|
||||
col_set_str(pinfo->cinfo, COL_PROTOCOL, "RX");
|
||||
if (check_col(pinfo->cinfo, COL_INFO))
|
||||
|
@ -582,6 +591,7 @@ dissect_rx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
|
|||
break;
|
||||
}
|
||||
|
||||
return(tvb_length(tvb));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -784,7 +794,7 @@ proto_reg_handoff_rx(void)
|
|||
|
||||
/* Ports in the range UDP_PORT_RX_LOW to UDP_PORT_RX_HIGH
|
||||
are all used for various AFS services. */
|
||||
rx_handle = create_dissector_handle(dissect_rx, proto_rx);
|
||||
rx_handle = new_create_dissector_handle(dissect_rx, proto_rx);
|
||||
for (port = UDP_PORT_RX_LOW; port <= UDP_PORT_RX_HIGH; port++)
|
||||
dissector_add("udp.port", port, rx_handle);
|
||||
dissector_add("udp.port", UDP_PORT_RX_AFS_BACKUPS, rx_handle);
|
||||
|
|
Loading…
Reference in New Issue