diff options
author | Irene Ruengeler <ruengeler@wireshark.org> | 2017-05-08 09:04:16 +0200 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2017-06-02 01:19:02 +0000 |
commit | e1f84f985eb4920bc3c0b58ca583bca1d2e93b1c (patch) | |
tree | e105e10d80c825eae5c58e139736ab4d64f2be24 /epan/dissectors/packet-tcp.c | |
parent | 653fc958979032009e0dd2bdfe2a23c338311805 (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-tcp.c')
-rw-r--r-- | epan/dissectors/packet-tcp.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/epan/dissectors/packet-tcp.c b/epan/dissectors/packet-tcp.c index b2aa3c8ea5..1e29f63896 100644 --- a/epan/dissectors/packet-tcp.c +++ b/epan/dissectors/packet-tcp.c @@ -617,31 +617,37 @@ const unit_name_string units_64bit_version = { " (64bits version)", NULL }; static void tcp_src_prompt(packet_info *pinfo, gchar *result) { - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "source (%u%s)", pinfo->srcport, UTF8_RIGHTWARDS_ARROW); + guint32 port = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, hf_tcp_srcport, pinfo->curr_layer_num)); + + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "source (%u%s)", port, UTF8_RIGHTWARDS_ARROW); } static gpointer tcp_src_value(packet_info *pinfo) { - return GUINT_TO_POINTER(pinfo->srcport); + return p_get_proto_data(pinfo->pool, pinfo, hf_tcp_srcport, pinfo->curr_layer_num); } static void tcp_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_tcp_dstport, pinfo->curr_layer_num)); + + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "destination (%s%u)", UTF8_RIGHTWARDS_ARROW, port); } static gpointer tcp_dst_value(packet_info *pinfo) { - return GUINT_TO_POINTER(pinfo->destport); + return p_get_proto_data(pinfo->pool, pinfo, hf_tcp_dstport, pinfo->curr_layer_num); } static void tcp_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_tcp_srcport, pinfo->curr_layer_num)), + destport = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, hf_tcp_dstport, pinfo->curr_layer_num)); + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "both (%u%s%u)", srcport, UTF8_LEFT_RIGHT_ARROW, destport); } static const char* tcp_conv_get_filter_type(conv_item_t* conv, conv_filter_type_e filter) @@ -5749,6 +5755,9 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) pinfo->srcport = tcph->th_sport; pinfo->destport = tcph->th_dport; + p_add_proto_data(pinfo->pool, pinfo, hf_tcp_srcport, pinfo->curr_layer_num, GUINT_TO_POINTER(tcph->th_sport)); + p_add_proto_data(pinfo->pool, pinfo, hf_tcp_dstport, pinfo->curr_layer_num, GUINT_TO_POINTER(tcph->th_dport)); + tcph->th_rawseq = tvb_get_ntohl(tvb, offset + 4); tcph->th_seq = tcph->th_rawseq; tcph->th_ack = tvb_get_ntohl(tvb, offset + 8); |