summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2006-10-31 01:28:29 +0000
committerGerald Combs <gerald@wireshark.org>2006-10-31 01:28:29 +0000
commitb61a0b3d16895a559c85b3dbe7252b7a32817726 (patch)
treee99d8b75c0791aee7f33661dc7ea55b7669509c9
parent5722c7bbae7817f8af30ca7df604d60cd34ccea0 (diff)
downloadwireshark-b61a0b3d16895a559c85b3dbe7252b7a32817726.tar.gz
Make sure we round up to the nearest 4-byte boundary before trying to process
the FCS. svn path=/trunk/; revision=19746
-rw-r--r--epan/dissectors/packet-radiotap.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/epan/dissectors/packet-radiotap.c b/epan/dissectors/packet-radiotap.c
index 31ecf563ea..40529a7d6a 100644
--- a/epan/dissectors/packet-radiotap.c
+++ b/epan/dissectors/packet-radiotap.c
@@ -199,6 +199,14 @@ dissect_radiotap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
#define BITNO_2(x) (((x) & 2) ? 1 : 0)
#define BIT(n) (1 << n)
+/*
+ * XXX - There are roundup macros defined in other dissectors. We should
+ * move them to a common location at some point.
+ */
+#ifndef roundup2
+#define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
+#endif
+
void
capture_radiotap(const guchar *pd, int offset, int len, packet_counts *ld)
{
@@ -652,7 +660,7 @@ dissect_radiotap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
if (tree) {
proto_tree_add_uint_format(radiotap_tree, hf_radiotap_datarate,
- tvb, offset, 1, tvb_get_guint8(tvb, offset),
+ tvb, offset, 1, tvb_get_guint8(tvb, offset),
"Data Rate: %d.%d Mb/s", rate / 2, rate & 1 ? 5 : 0);
}
offset++;
@@ -783,7 +791,8 @@ dissect_radiotap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
length_remaining-=2;
break;
case IEEE80211_RADIOTAP_FCS:
- /* This handles the case of an FCS exiting inside the radiotap header. */
+ /* This handles the case of an FCS existing inside the radiotap header. */
+ offset = roundup2(offset, 4);
if (length_remaining < 4)
break;
if (tree) {