aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-gsm_a_common.h
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2017-01-27 18:20:40 +0100
committerAlexis La Goutte <alexis.lagoutte@gmail.com>2017-02-01 08:58:14 +0000
commit5dde07c8fdb2e17c4d4142427fe29f7db66c1965 (patch)
tree21908b58c79d54f95ae3cfe0c76bd49638ec5e17 /epan/dissectors/packet-gsm_a_common.h
parent275594231dc1f4a08f24123e4413acfd11b59d4e (diff)
GSM A / NAS-EPS: detect missing mandatory information elements
Current code is not able to detect missing mandatory information elements because the macro will return once the end of the payload is reached. Remove this check from all mandatory IE macros, and put it at the beginning of optional IE ones. It should allow to detect any missing mandatory IE while still stopping message dissection in case optional IEs are not present. Change-Id: Ie820740e25c1d03ee3462fa4a913c3a7870fcc2d Reviewed-on: https://code.wireshark.org/review/19816 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-gsm_a_common.h')
-rw-r--r--epan/dissectors/packet-gsm_a_common.h20
1 files changed, 6 insertions, 14 deletions
diff --git a/epan/dissectors/packet-gsm_a_common.h b/epan/dissectors/packet-gsm_a_common.h
index 91bc4ea0dd..6a259b1307 100644
--- a/epan/dissectors/packet-gsm_a_common.h
+++ b/epan/dissectors/packet-gsm_a_common.h
@@ -411,7 +411,6 @@ WS_DLL_PUBLIC guint16 elem_v_short(tvbuff_t *tvb, proto_tree *tree, packet_info
(EMT_elem_name_addition == NULL) ? "" : EMT_elem_name_addition \
); \
} \
- if ((signed)curr_len <= 0) return; \
}
/* This is a version where the length field can be one or two octets depending
* if the extension bit is set or not (TS 48.016 p 10.1.2).
@@ -437,7 +436,6 @@ WS_DLL_PUBLIC guint16 elem_v_short(tvbuff_t *tvb, proto_tree *tree, packet_info
(EMT_elem_name_addition == NULL) ? "" : EMT_elem_name_addition \
); \
} \
- if ((signed)curr_len <= 0) return; \
}
#define ELEM_MAND_TLV_E(EMT_iei, EMT_pdu_type, EMT_elem_idx, EMT_elem_name_addition, ei_mandatory) \
@@ -458,36 +456,35 @@ WS_DLL_PUBLIC guint16 elem_v_short(tvbuff_t *tvb, proto_tree *tree, packet_info
(EMT_elem_name_addition == NULL) ? "" : EMT_elem_name_addition \
); \
} \
- if ((signed)curr_len <= 0) return; \
}
#define ELEM_OPT_TLV(EOT_iei, EOT_pdu_type, EOT_elem_idx, EOT_elem_name_addition) \
{\
+ if ((signed)curr_len <= 0) return; \
if ((consumed = elem_tlv(tvb, tree, pinfo, (guint8) EOT_iei, EOT_pdu_type, EOT_elem_idx, curr_offset, curr_len, EOT_elem_name_addition)) > 0) \
{ \
curr_offset += consumed; \
curr_len -= consumed; \
} \
- if ((signed)curr_len <= 0) return; \
}
#define ELEM_OPT_TELV(EOT_iei, EOT_pdu_type, EOT_elem_idx, EOT_elem_name_addition) \
{\
+ if ((signed)curr_len <= 0) return; \
if ((consumed = elem_telv(tvb, tree, pinfo, (guint8) EOT_iei, EOT_pdu_type, EOT_elem_idx, curr_offset, curr_len, EOT_elem_name_addition)) > 0) \
{ \
curr_offset += consumed; \
curr_len -= consumed; \
} \
- if ((signed)curr_len <= 0) return; \
}
#define ELEM_OPT_TLV_E(EOT_iei, EOT_pdu_type, EOT_elem_idx, EOT_elem_name_addition) \
{\
+ if ((signed)curr_len <= 0) return; \
if ((consumed = elem_tlv_e(tvb, tree, pinfo, (guint8) EOT_iei, EOT_pdu_type, EOT_elem_idx, curr_offset, curr_len, EOT_elem_name_addition)) > 0) \
{ \
curr_offset += consumed; \
curr_len -= consumed; \
} \
- if ((signed)curr_len <= 0) return; \
}
#define ELEM_MAND_TV(EMT_iei, EMT_pdu_type, EMT_elem_idx, EMT_elem_name_addition, ei_mandatory) \
@@ -508,37 +505,36 @@ WS_DLL_PUBLIC guint16 elem_v_short(tvbuff_t *tvb, proto_tree *tree, packet_info
(EMT_elem_name_addition == NULL) ? "" : EMT_elem_name_addition \
); \
} \
- if ((signed)curr_len <= 0) return; \
}
#define ELEM_OPT_TV(EOT_iei, EOT_pdu_type, EOT_elem_idx, EOT_elem_name_addition) \
{\
+ if ((signed)curr_len <= 0) return; \
if ((consumed = elem_tv(tvb, tree, pinfo, (guint8) EOT_iei, EOT_pdu_type, EOT_elem_idx, curr_offset, EOT_elem_name_addition)) > 0) \
{ \
curr_offset += consumed; \
curr_len -= consumed; \
} \
- if ((signed)curr_len <= 0) return; \
}
#define ELEM_OPT_TV_SHORT(EOT_iei, EOT_pdu_type, EOT_elem_idx, EOT_elem_name_addition) \
{\
+ if ((signed)curr_len <= 0) return; \
if ((consumed = elem_tv_short(tvb, tree, pinfo, EOT_iei, EOT_pdu_type, EOT_elem_idx, curr_offset, EOT_elem_name_addition)) > 0) \
{ \
curr_offset += consumed; \
curr_len -= consumed; \
} \
- if ((signed)curr_len <= 0) return; \
}
#define ELEM_OPT_T(EOT_iei, EOT_pdu_type, EOT_elem_idx, EOT_elem_name_addition) \
{\
+ if ((signed)curr_len <= 0) return; \
if ((consumed = elem_t(tvb, tree, pinfo, (guint8) EOT_iei, EOT_pdu_type, EOT_elem_idx, curr_offset, EOT_elem_name_addition)) > 0) \
{ \
curr_offset += consumed; \
curr_len -= consumed; \
} \
- if ((signed)curr_len <= 0) return; \
}
#define ELEM_MAND_LV(EML_pdu_type, EML_elem_idx, EML_elem_name_addition) \
@@ -552,7 +548,6 @@ WS_DLL_PUBLIC guint16 elem_v_short(tvbuff_t *tvb, proto_tree *tree, packet_info
{ \
/* Mandatory, but nothing we can do */ \
} \
- if ((signed)curr_len <= 0) return; \
}
#define ELEM_MAND_LV_E(EML_pdu_type, EML_elem_idx, EML_elem_name_addition) \
@@ -566,7 +561,6 @@ WS_DLL_PUBLIC guint16 elem_v_short(tvbuff_t *tvb, proto_tree *tree, packet_info
{ \
/* Mandatory, but nothing we can do */ \
} \
- if ((signed)curr_len <= 0) return; \
}
#define ELEM_MAND_V(EMV_pdu_type, EMV_elem_idx, EMV_elem_name_addition) \
@@ -580,7 +574,6 @@ WS_DLL_PUBLIC guint16 elem_v_short(tvbuff_t *tvb, proto_tree *tree, packet_info
{ \
/* Mandatory, but nothing we can do */ \
} \
- if ((signed)curr_len <= 0) return; \
}
#define ELEM_MAND_VV_SHORT(EMV_pdu_type1, EMV_elem_idx1, EMV_pdu_type2, EMV_elem_idx2) \
@@ -589,7 +582,6 @@ WS_DLL_PUBLIC guint16 elem_v_short(tvbuff_t *tvb, proto_tree *tree, packet_info
elem_v_short(tvb, tree, pinfo, EMV_pdu_type2, EMV_elem_idx2, curr_offset, LEFT_NIBBLE); \
curr_offset ++ ; /* consumed length is 1, regardless of contents */ \
curr_len -- ; \
- if ((signed)curr_len <= 0) return; \
}
/*