ICMP(v4): fix Found soft-deprecated APIs (tvb_length,tvb_length_remaining)

Change-Id: Ib79a55d4f2459119feff29aa06dc8eda8bea6954
Reviewed-on: https://code.wireshark.org/review/7608
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Alexis La Goutte 2015-03-09 08:42:18 +01:00 committed by Anders Broman
parent 296bb23697
commit e9a4010630
1 changed files with 7 additions and 7 deletions

View File

@ -1200,7 +1200,7 @@ dissect_icmp(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data)
guint8 icmp_type;
guint8 icmp_code;
guint8 icmp_original_dgram_length;
guint length, reported_length;
guint captured_length, reported_length;
guint16 cksum, computed_cksum;
const gchar *type_str, *code_str;
guint8 num_addrs = 0;
@ -1282,10 +1282,10 @@ dissect_icmp(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data)
col_append_fstr(pinfo->cinfo, COL_INFO, " (%s)", code_str);
}
length = tvb_length(tvb);
captured_length = tvb_captured_length(tvb);
reported_length = tvb_reported_length(tvb);
ti = proto_tree_add_item(tree, proto_icmp, tvb, 0, length, ENC_NA);
ti = proto_tree_add_item(tree, proto_icmp, tvb, 0, captured_length, ENC_NA);
icmp_tree = proto_item_add_subtree(ti, ett_icmp);
ti = proto_tree_add_item(icmp_tree, hf_icmp_type, tvb, 0, 1,
@ -1298,7 +1298,7 @@ dissect_icmp(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data)
proto_item_append_text(ti, " (%s)", code_str);
}
if (!pinfo->fragmented && length >= reported_length
if (!pinfo->fragmented && captured_length >= reported_length
&& !pinfo->flags.in_error_pkt) {
/* The packet isn't part of a fragmented datagram, isn't
truncated, and isn't the payload of an error packet, so we can checksum
@ -1541,8 +1541,8 @@ dissect_icmp(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data)
/* Make sure we have enough bytes in the payload before trying to
* see if the data looks like a timestamp; otherwise we'll get
* malformed packets as we try to access data that isn't there. */
if (tvb_length_remaining(tvb, 8) < 8) {
if (tvb_length_remaining(tvb, 8) > 0) {
if (tvb_captured_length_remaining(tvb, 8) < 8) {
if (tvb_captured_length_remaining(tvb, 8) > 0) {
call_dissector(data_handle,
tvb_new_subset_remaining
(tvb, 8), pinfo, icmp_tree);
@ -1658,7 +1658,7 @@ dissect_icmp(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data)
tap_queue_packet(icmp_tap, pinfo, trans);
}
return tvb_length(tvb);
return tvb_reported_length(tvb);
}
void proto_register_icmp(void)