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-dtls.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-dtls.c')
-rw-r--r-- | epan/dissectors/packet-dtls.c | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/epan/dissectors/packet-dtls.c b/epan/dissectors/packet-dtls.c index d75ddc65a6..2dbf8532d6 100644 --- a/epan/dissectors/packet-dtls.c +++ b/epan/dissectors/packet-dtls.c @@ -57,6 +57,7 @@ #include <epan/sctpppids.h> #include <epan/exported_pdu.h> #include <epan/decode_as.h> +#include <epan/proto_data.h> #include <wsutil/str_util.h> #include <wsutil/strtoi.h> #include <wsutil/utf8_entities.h> @@ -1660,31 +1661,68 @@ dtlsdecrypt_uat_fld_protocol_chk_cb(void* r _U_, const char* p, guint len _U_, c static void dtls_src_prompt(packet_info *pinfo, gchar *result) { - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "source (%u%s)", pinfo->srcport, UTF8_RIGHTWARDS_ARROW); + SslPacketInfo* pi; + guint32 srcport = pinfo->srcport; + + pi = (SslPacketInfo *)p_get_proto_data(wmem_file_scope(), pinfo, proto_dtls, pinfo->curr_layer_num); + if (pi != NULL) + srcport = pi->srcport; + + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "source (%u%s)", srcport, UTF8_RIGHTWARDS_ARROW); } static gpointer dtls_src_value(packet_info *pinfo) { - return GUINT_TO_POINTER(pinfo->srcport); + SslPacketInfo* pi; + + pi = (SslPacketInfo *)p_get_proto_data(wmem_file_scope(), pinfo, proto_dtls, pinfo->curr_layer_num); + if (pi == NULL) + return GUINT_TO_POINTER(pinfo->srcport); + + return GUINT_TO_POINTER(pi->srcport); } static void dtls_dst_prompt(packet_info *pinfo, gchar *result) { - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "destination (%s%u)", UTF8_RIGHTWARDS_ARROW, pinfo->destport); + SslPacketInfo* pi; + guint32 destport = pinfo->destport; + + pi = (SslPacketInfo *)p_get_proto_data(wmem_file_scope(), pinfo, proto_dtls, pinfo->curr_layer_num); + if (pi != NULL) + destport = pi->destport; + + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "destination (%s%u)", UTF8_RIGHTWARDS_ARROW, destport); } static gpointer dtls_dst_value(packet_info *pinfo) { - return GUINT_TO_POINTER(pinfo->destport); + SslPacketInfo* pi; + + pi = (SslPacketInfo *)p_get_proto_data(wmem_file_scope(), pinfo, proto_dtls, pinfo->curr_layer_num); + if (pi == NULL) + return GUINT_TO_POINTER(pinfo->destport); + + return GUINT_TO_POINTER(pi->destport); } static void dtls_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); + SslPacketInfo* pi; + guint32 srcport = pinfo->srcport, + destport = pinfo->destport; + + pi = (SslPacketInfo *)p_get_proto_data(wmem_file_scope(), pinfo, proto_dtls, pinfo->curr_layer_num); + if (pi != NULL) + { + srcport = pi->srcport; + destport = pi->destport; + } + + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "both (%u%s%u)", srcport, UTF8_LEFT_RIGHT_ARROW, destport); } void proto_reg_handoff_dtls(void); |