aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-cmpp.c
diff options
context:
space:
mode:
authorJeff Morriss <jeff.morriss@ulticom.com>2008-01-17 22:05:06 +0000
committerJeff Morriss <jeff.morriss@ulticom.com>2008-01-17 22:05:06 +0000
commita07aa79b6b6659e9974208b5e51f6b7993d9e683 (patch)
tree5b42f89d580a07b48adc399cae536d8826e3aff7 /epan/dissectors/packet-cmpp.c
parentf136a90eff886c61ae1daea47f6a0aa142a26bfe (diff)
Strengthen heuristics a little bit, remove a useless variable, put COL_INFO check in the right place
svn path=/trunk/; revision=24126
Diffstat (limited to 'epan/dissectors/packet-cmpp.c')
-rw-r--r--epan/dissectors/packet-cmpp.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/epan/dissectors/packet-cmpp.c b/epan/dissectors/packet-cmpp.c
index dc4a9371dd..20f6ed6721 100644
--- a/epan/dissectors/packet-cmpp.c
+++ b/epan/dissectors/packet-cmpp.c
@@ -564,10 +564,11 @@ dissect_cmpp_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
total_length = tvb_get_ntohl(tvb, 0); /* Get the pdu length */
command_id = tvb_get_ntohl(tvb, 4); /* get the pdu command id */
- if (check_col(pinfo->cinfo, COL_INFO) && match_strval(command_id, vals_command_Id) == NULL)
+ if (match_strval(command_id, vals_command_Id) == NULL)
{
- col_append_fstr(pinfo->cinfo, COL_INFO, "Unknown command_id %u",
- command_id);
+ if (check_col(pinfo->cinfo, COL_INFO))
+ col_append_fstr(pinfo->cinfo, COL_INFO, "Unknown command_id %u",
+ command_id);
return;
}
@@ -575,10 +576,11 @@ dissect_cmpp_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
"(Unknown CMPP Operation 0x%08X)");
/* tvb has less data then the PDU Header status, return */
- if (check_col(pinfo->cinfo, COL_INFO) && tvb_len < total_length)
+ if (tvb_len < total_length)
{
- col_append_fstr(pinfo->cinfo, COL_INFO, "%s pdu length (%u) < Total_Length (%u)",
- command_str, tvb_len, total_length);
+ if (check_col(pinfo->cinfo, COL_INFO))
+ col_append_fstr(pinfo->cinfo, COL_INFO, "%s pdu length (%u) < Total_Length (%u)",
+ command_str, tvb_len, total_length);
return;
}
@@ -593,7 +595,6 @@ dissect_cmpp_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if (tree)
{
-
ti = proto_tree_add_item(tree, proto_cmpp, tvb, 0, -1, FALSE);
cmpp_tree = proto_item_add_subtree(ti, ett_cmpp);
@@ -648,15 +649,15 @@ get_cmpp_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, gint offset)
static int
dissect_cmpp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
- guint total_length, command_id, sequence_id; /* Fix Header field */
+ guint total_length, command_id, tvb_len;
/* Check that there's enough data */
- if (tvb_length(tvb) < CMPP_FIX_HEADER_LENGTH)
+ tvb_len = tvb_length(tvb);
+ if (tvb_len < CMPP_FIX_HEADER_LENGTH)
return 0;
/* Get some values from the packet header, probably using tvb_get_*() */
total_length = tvb_get_ntohl(tvb, 0); /* Get the pdu length */
command_id = tvb_get_ntohl(tvb, 4); /* get the pdu command id */
- sequence_id = tvb_get_ntohl(tvb, 8); /* get the sequence id */
if (match_strval(command_id, vals_command_Id) == NULL)
/* This packet does not appear to belong to CMPP.
@@ -664,6 +665,9 @@ dissect_cmpp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
*/
return 0;
+ if (tvb_len < total_length || total_length < CMPP_FIX_HEADER_LENGTH)
+ return 0;
+
if (check_col(pinfo->cinfo, COL_INFO))
col_clear(pinfo->cinfo, COL_INFO);