diff options
author | Michael Mann <mmann78@netscape.net> | 2017-05-21 08:12:15 -0400 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2017-05-22 15:28:49 +0000 |
commit | d4725439c1728a56e13110ae66389b28b4091403 (patch) | |
tree | 1e4eca0290b444bdddea0f034f397f2c26c988fa /epan | |
parent | 8cdbde02c9c949f7c9069623650d2eba70bdd1dc (diff) |
packet-dccp.c: Don't use tvb_get_ptr for getting a uint number.
Use the tvb_get_ntohXXX instead.
Change-Id: I8d5c6ac2f2c8b1ac9237297f06709513fc2c9113
Reviewed-on: https://code.wireshark.org/review/21733
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/packet-dccp.c | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/epan/dissectors/packet-dccp.c b/epan/dissectors/packet-dccp.c index 1415042a10..be8988c3da 100644 --- a/epan/dissectors/packet-dccp.c +++ b/epan/dissectors/packet-dccp.c @@ -315,24 +315,35 @@ decode_dccp_ports(tvbuff_t *tvb, int offset, packet_info *pinfo, * a concept by Arnaldo de Melo */ static guint64 -tvb_get_ntoh_var(tvbuff_t *tvb, gint offset, guint nbytes) +dccp_ntoh_var(tvbuff_t *tvb, gint offset, guint nbytes) { - const guint8 *ptr; guint64 value = 0; - ptr = tvb_get_ptr(tvb, offset, nbytes); - if (nbytes > 5) - value += ((guint64) * ptr++) << 40; - if (nbytes > 4) - value += ((guint64) * ptr++) << 32; - if (nbytes > 3) - value += ((guint64) * ptr++) << 24; - if (nbytes > 2) - value += ((guint64) * ptr++) << 16; - if (nbytes > 1) - value += ((guint64) * ptr++) << 8; - if (nbytes > 0) - value += *ptr; + switch (nbytes) + { + case 5: + value = tvb_get_ntoh40(tvb, offset); + break; + case 4: + value = tvb_get_ntohl(tvb, offset); + break; + case 3: + value = tvb_get_ntoh24(tvb, offset); + break; + case 2: + value = tvb_get_ntohs(tvb, offset); + break; + case 1: + value = tvb_get_guint8(tvb, offset); + break; + case 0: + // do nothing + break; + case 6: + default: + value = tvb_get_ntoh48(tvb, offset); + break; + } return value; } @@ -385,7 +396,7 @@ dissect_feature_options(proto_tree *dccp_options_tree, tvbuff_t *tvb, if (option_len > 0) /* could be empty Confirm */ proto_item_append_text(dccp_item, " %" G_GINT64_MODIFIER "u", - tvb_get_ntoh_var(tvb, offset, option_len)); + dccp_ntoh_var(tvb, offset, option_len)); break; /* Reserved, specific, or unknown features */ @@ -469,8 +480,7 @@ dissect_options(tvbuff_t *tvb, packet_info *pinfo, expert_add_info_format(pinfo, option_item, &ei_dccp_option_len_bad, "NDP Count too long (max 6 bytes)"); else - proto_tree_add_uint64(option_tree, hf_dccp_ndp_count, tvb, offset, option_len, - tvb_get_ntoh_var(tvb, offset, option_len)); + proto_tree_add_item(option_tree, hf_dccp_ndp_count, tvb, offset, option_len, ENC_BIG_ENDIAN); break; case 38: proto_tree_add_item(option_tree, hf_dccp_ack_vector_nonce_0, tvb, offset, option_len, ENC_NA); |