aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-diameter.c
diff options
context:
space:
mode:
authorJeff Morriss <jeff.morriss.ws@gmail.com>2014-04-06 19:59:52 -0400
committerAnders Broman <a.broman58@gmail.com>2014-04-07 04:12:13 +0000
commit26dcdbb402751df9e51c397c42f3545d8e08ccbe (patch)
treef316ed7f7e4ff77c2cda48cd859bf042a1c90f01 /epan/dissectors/packet-diameter.c
parent58a6487b540ee2eb30753573ba84b3837f6d9471 (diff)
Tweak the Diameter heuristics a bit more.
Increase the max Diameter message size to 65534 and reject messages whose flags have both the E- and R-bits set. Change-Id: Ib11701a47d23ff042a346d59c56f9f0f4410e6b7 Reviewed-on: https://code.wireshark.org/review/990 Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-diameter.c')
-rw-r--r--epan/dissectors/packet-diameter.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/epan/dissectors/packet-diameter.c b/epan/dissectors/packet-diameter.c
index 8bda23cd66..ce824afd5e 100644
--- a/epan/dissectors/packet-diameter.c
+++ b/epan/dissectors/packet-diameter.c
@@ -1243,6 +1243,7 @@ static gboolean
check_diameter(tvbuff_t *tvb)
{
guint32 diam_len;
+ guint8 flags;
/* Ensure we don't throw an exception trying to do these heuristics */
if (tvb_length(tvb) < 5)
@@ -1257,18 +1258,26 @@ check_diameter(tvbuff_t *tvb)
* is just a practical one (feel free to tune it).
*/
diam_len = tvb_get_ntoh24(tvb, 1);
- if (diam_len > 8192)
+ if (diam_len > 65534)
return FALSE;
+ flags = tvb_get_guint8(tvb, 4);
+
/* Check if any of the Reserved flag bits are set */
- if (tvb_get_guint8(tvb, 4) & 0x0f)
+ if (flags & 0x0f)
+ return FALSE;
+
+ /* Check if both the R- and E-bits are set */
+ if ((flags & DIAM_FLAGS_R) && (flags & DIAM_FLAGS_E))
return FALSE;
return TRUE;
}
-/************************************************/
-/* Main dissection function */
+/*****************************************************************/
+/* Main dissection function */
+/* Checks if the message looks like Diameter before accepting it */
+/*****************************************************************/
static int
dissect_diameter(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
@@ -1278,7 +1287,7 @@ dissect_diameter(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data
}
static int
-dissect_diameter_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
+dissect_diameter_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
/* Check if we have the start of a PDU or if this is segment */
if (!check_diameter(tvb)) {