aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-sctp.c
diff options
context:
space:
mode:
authorIrene Ruengeler <ruengeler@wireshark.org>2017-05-08 09:04:16 +0200
committerMichael Mann <mmann78@netscape.net>2017-06-02 01:19:02 +0000
commite1f84f985eb4920bc3c0b58ca583bca1d2e93b1c (patch)
treee105e10d80c825eae5c58e139736ab4d64f2be24 /epan/dissectors/packet-sctp.c
parent653fc958979032009e0dd2bdfe2a23c338311805 (diff)
Fix Decode As for protocols that may use tunneling.
Dissectors that rely on pinfo structure information may have the data overwritten if the data is tunneled. Address it by using proto data that is based on pinfo->curr_layer_num. Bug: 13746 Change-Id: I1c29f26a3c49f368876f0e96908705bc9c099ce1 Reviewed-on: https://code.wireshark.org/review/21559 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/dissectors/packet-sctp.c')
-rw-r--r--epan/dissectors/packet-sctp.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/epan/dissectors/packet-sctp.c b/epan/dissectors/packet-sctp.c
index 7b150a5ba6..11ee2e85d4 100644
--- a/epan/dissectors/packet-sctp.c
+++ b/epan/dissectors/packet-sctp.c
@@ -740,40 +740,44 @@ find_assoc_index(assoc_info_t* tmpinfo, gboolean visited)
static void
sctp_src_prompt(packet_info *pinfo, gchar *result)
{
- g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "source (%s%u)", UTF8_RIGHTWARDS_ARROW, pinfo->srcport);
+ guint32 port = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, hf_source_port, pinfo->curr_layer_num));
+
+ g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "source (%s%u)", UTF8_RIGHTWARDS_ARROW, port);
}
static gpointer
sctp_src_value(packet_info *pinfo)
{
- return GUINT_TO_POINTER(pinfo->srcport);
+ return p_get_proto_data(pinfo->pool, pinfo, hf_source_port, pinfo->curr_layer_num);
}
static void
sctp_dst_prompt(packet_info *pinfo, gchar *result)
{
- g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "destination (%s%u)", UTF8_RIGHTWARDS_ARROW, pinfo->destport);
+ guint32 port = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, hf_destination_port, pinfo->curr_layer_num));
+
+ g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "destination (%s%u)", UTF8_RIGHTWARDS_ARROW, port);
}
static gpointer
sctp_dst_value(packet_info *pinfo)
{
- return GUINT_TO_POINTER(pinfo->destport);
+ return p_get_proto_data(pinfo->pool, pinfo, hf_destination_port, pinfo->curr_layer_num);
}
static void
sctp_both_prompt(packet_info *pinfo, gchar *result)
{
- g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "both (%u%s%u)", pinfo->srcport, UTF8_LEFT_RIGHT_ARROW, pinfo->destport);
+ guint32 srcport = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, hf_source_port, pinfo->curr_layer_num)),
+ destport = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, hf_destination_port, pinfo->curr_layer_num));
+
+ g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "both (%u%s%u)", srcport, UTF8_LEFT_RIGHT_ARROW, destport);
}
static void
sctp_ppi_prompt1(packet_info *pinfo _U_, gchar* result)
{
- guint32 ppid;
- void *tmp = p_get_proto_data(pinfo->pool, pinfo, proto_sctp, 0);
-
- ppid = GPOINTER_TO_UINT(tmp);
+ guint32 ppid = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_sctp, 0));
if (ppid == LAST_PPID) {
g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "PPID (none)");
@@ -785,10 +789,7 @@ sctp_ppi_prompt1(packet_info *pinfo _U_, gchar* result)
static void
sctp_ppi_prompt2(packet_info *pinfo _U_, gchar* result)
{
- guint32 ppid;
- void *tmp = p_get_proto_data(pinfo->pool, pinfo, proto_sctp, 1);
-
- ppid = GPOINTER_TO_UINT(tmp);
+ guint32 ppid = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_sctp, 1));
if (ppid == LAST_PPID) {
g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "PPID (none)");
@@ -4783,6 +4784,9 @@ dissect_sctp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
set_address(&sctp_info.ip_src, pinfo->src.type, pinfo->src.len, pinfo->src.data);
set_address(&sctp_info.ip_dst, pinfo->dst.type, pinfo->dst.len, pinfo->dst.data);
+ p_add_proto_data(pinfo->pool, pinfo, hf_source_port, pinfo->curr_layer_num, GUINT_TO_POINTER(pinfo->srcport));
+ p_add_proto_data(pinfo->pool, pinfo, hf_destination_port, pinfo->curr_layer_num, GUINT_TO_POINTER(pinfo->destport));
+
dissect_sctp_packet(tvb, pinfo, tree, FALSE);
if (!pinfo->flags.in_error_pkt && sctp_info.number_of_tvbs > 0)
tap_queue_packet(sctp_tap, pinfo, &sctp_info);