aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2011-12-10 05:29:09 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2011-12-10 05:29:09 +0000
commit5270191f7fae6205e5e9e5014c200fa1b0fb2543 (patch)
tree0274298cec725e8acd9c8c0f853b1b90c991dfb5
parent2de242ef95c6686bcbb712d7810f78e7bef443e5 (diff)
Clean up indentation.
Do more length checks, so we reject trailers that have nothing to dissect. Test for the trailer length being >= 8, rather than for having the 0x08 bit set (they amount to the same thing, as the trailer length is <= 14, and >= 8 is what we really want if we're checking whether there's a timestamp). git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@40142 f5534014-38df-0310-8fa8-9805f1628bb7
-rw-r--r--epan/dissectors/packet-vssmonitoring.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/epan/dissectors/packet-vssmonitoring.c b/epan/dissectors/packet-vssmonitoring.c
index 5028b60aee..5337f77716 100644
--- a/epan/dissectors/packet-vssmonitoring.c
+++ b/epan/dissectors/packet-vssmonitoring.c
@@ -64,7 +64,7 @@ static gboolean vssmonitoring_use_heuristics = TRUE;
static int
dissect_vssmonitoring(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
- proto_tree *ti = NULL;
+ proto_tree *ti = NULL;
proto_tree *vssmonitoring_tree = NULL;
guint offset = 0;
@@ -84,7 +84,19 @@ dissect_vssmonitoring(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
* port stamp (1 or 2 bytes)
* fcs (4 bytes)
*
- * This means a trailer length must not be more than 14 bytes
+ * The FCS is dissected by our caller, so we check for a trailer
+ * with a length that includes one or more of a time stamp and
+ * a 1-byte or 2-byte port stamp.
+ *
+ * This means a trailer length must not be more than 14 bytes,
+ * and:
+ *
+ * must not be 3 modulo 3 (as it can't have both a 1-byte
+ * and a 2-byte port stamp);
+ *
+ * if it's less than 8 bytes, must not be 0 modulo 3 (as
+ * it must have a 1-byte or 2-byte port stamp, given that
+ * it has no timestamp).
*/
if ( trailer_len > 14 )
return 0;
@@ -95,7 +107,13 @@ dissect_vssmonitoring(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if ( (trailer_len & 3) == 3 )
return 0;
- if ( trailer_len & 8 ) {
+ /* ... and if you have neither a time stamp nor a port stamp,
+ * you don't have a trailer
+ */
+ if ( (trailer_len & 3) == 0 && trailer_len < 8 )
+ return 0;
+
+ if ( trailer_len >= 8 ) {
vssmonitoring_time.secs = tvb_get_ntohl(tvb, offset);
vssmonitoring_time.nsecs = tvb_get_ntohl(tvb, offset + 4);
vssmonitoring_clksrc = (guint8)(((guint32)vssmonitoring_time.nsecs) >> CLKSRC_SHIFT);
@@ -137,7 +155,7 @@ dissect_vssmonitoring(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
/* Do we have a timestamp? */
- if ( trailer_len & 8 ) {
+ if ( trailer_len >= 8 ) {
if (tree) {
proto_tree_add_time(vssmonitoring_tree, hf_vssmonitoring_time, tvb, offset, 8, &vssmonitoring_time);
proto_tree_add_uint(vssmonitoring_tree, hf_vssmonitoring_clksrc, tvb, offset + 4, 1, vssmonitoring_clksrc);