aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2017-12-10 23:09:54 +0100
committerMichael Mann <mmann78@netscape.net>2017-12-11 02:22:53 +0000
commit224e24884a8b37732105bd40a0ee85d5feaaeab1 (patch)
treef2a0bf8e2e773d84da1993d20e3e09d490a52ee2
parent7d383637865e2f1f0de7a8921261f406f42af4bf (diff)
NTP: fix authenticator dissection when padding is used
Bug: 14269 Change-Id: Ifdc9af7524a0566e33acbedff3757cff416ce8fb Reviewed-on: https://code.wireshark.org/review/24758 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r--epan/dissectors/packet-ntp.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/epan/dissectors/packet-ntp.c b/epan/dissectors/packet-ntp.c
index d7bcb0c..b6992ea 100644
--- a/epan/dissectors/packet-ntp.c
+++ b/epan/dissectors/packet-ntp.c
@@ -495,6 +495,7 @@ static int hf_ntp_rec = -1;
static int hf_ntp_xmt = -1;
static int hf_ntp_keyid = -1;
static int hf_ntp_mac = -1;
+static int hf_ntp_padding = -1;
static int hf_ntp_key_type = -1;
static int hf_ntp_key_index = -1;
static int hf_ntp_key_signature = -1;
@@ -1046,7 +1047,7 @@ dissect_ntp_ctrl(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *ntp_tree)
guint16 associd;
guint16 datalen;
guint16 data_offset;
- int length_remaining;
+ gint length_remaining;
tvbparse_t *tt;
tvbparse_elem_t *element;
@@ -1199,13 +1200,23 @@ dissect_ntp_ctrl(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *ntp_tree)
}
data_offset = 12+datalen;
- length_remaining = tvb_reported_length_remaining(tvb, data_offset);
/* Check if there is authentication */
if ((flags2 & NTPCTRL_R_MASK) == 0)
{
- if (length_remaining > 0)
+ gint padding_length;
+
+ length_remaining = tvb_reported_length_remaining(tvb, data_offset);
+ /* Check padding presence */
+ padding_length = (data_offset & 7) ? 8 - (data_offset & 7) : 0;
+ if (length_remaining > padding_length)
{
+ if (padding_length)
+ {
+ proto_tree_add_item(ntp_tree, hf_ntp_padding, tvb, data_offset, padding_length, ENC_NA);
+ data_offset += padding_length;
+ length_remaining -= padding_length;
+ }
auth_tree = proto_tree_add_subtree(ntp_tree, tvb, data_offset, -1, ett_ntp_authenticator, NULL, "Authenticator");
switch (length_remaining)
{
@@ -1450,6 +1461,9 @@ proto_register_ntp(void)
{ &hf_ntp_mac, {
"Message Authentication Code", "ntp.mac", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL }},
+ { &hf_ntp_padding, {
+ "Padding", "ntp.padding", FT_BYTES, BASE_NONE,
+ NULL, 0, NULL, HFILL }},
{ &hf_ntp_key_type, {
"Key type", "ntp.key_type", FT_UINT8, BASE_DEC,
VALS(authentication_types), 0, "Authentication algorithm used", HFILL }},