forked from osmocom/wireshark
6lowpan: fix handling of UDP packets without payload
Replace all calls of tvb_ensure_captured_length_remaining with tvb_ensure_length_remaining as they are only used to ensure that already read data is present and it is not always required that at least 1 more byte follows. Change-Id: I71b1142c0d8f8fe3ddb09b80b6ca8ed10e0b67b6 Reviewed-on: https://code.wireshark.org/review/30517 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
c29c652eb9
commit
55d8c445b4
|
@ -1758,7 +1758,7 @@ dissect_6lowpan_hc1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint dg
|
|||
|
||||
/* Construct the next header for the UDP datagram. */
|
||||
offset = BITS_TO_BYTE_LEN(0, bit_offset);
|
||||
length = (gint)tvb_ensure_captured_length_remaining(tvb, offset);
|
||||
length = tvb_captured_length_remaining(tvb, offset);
|
||||
nhdr_list = (struct lowpan_nhdr *)wmem_alloc(wmem_packet_scope(), sizeof(struct lowpan_nhdr) + sizeof(struct udp_hdr) + length);
|
||||
nhdr_list->next = NULL;
|
||||
nhdr_list->proto = IP_PROTO_UDP;
|
||||
|
@ -1776,7 +1776,7 @@ dissect_6lowpan_hc1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint dg
|
|||
else {
|
||||
gint length;
|
||||
offset = BITS_TO_BYTE_LEN(0, bit_offset);
|
||||
length = (gint)tvb_ensure_captured_length_remaining(tvb, offset);
|
||||
length = tvb_captured_length_remaining(tvb, offset);
|
||||
nhdr_list = (struct lowpan_nhdr *)wmem_alloc(wmem_packet_scope(), sizeof(struct lowpan_nhdr) + length);
|
||||
nhdr_list->next = NULL;
|
||||
nhdr_list->proto = ipv6.ip6h_nxt;
|
||||
|
@ -2214,7 +2214,7 @@ dissect_6lowpan_iphc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint d
|
|||
}
|
||||
/* Create an extension header for the remaining payload. */
|
||||
else {
|
||||
length = (gint)tvb_ensure_captured_length_remaining(tvb, offset);
|
||||
length = tvb_captured_length_remaining(tvb, offset);
|
||||
nhdr_list = (struct lowpan_nhdr *)wmem_alloc(wmem_packet_scope(), sizeof(struct lowpan_nhdr) + length);
|
||||
nhdr_list->next = NULL;
|
||||
nhdr_list->proto = ipv6.ip6h_nxt;
|
||||
|
@ -2424,7 +2424,7 @@ dissect_6lowpan_iphc_nhc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gi
|
|||
}
|
||||
else if (ipv6_ext.ip6e_nxt != IP_PROTO_NONE) {
|
||||
/* Create another next header structure for the remaining payload. */
|
||||
length = (gint)tvb_ensure_captured_length_remaining(tvb, offset);
|
||||
length = tvb_captured_length_remaining(tvb, offset);
|
||||
nhdr->next = (struct lowpan_nhdr *)wmem_alloc(wmem_packet_scope(), sizeof(struct lowpan_nhdr) + length);
|
||||
nhdr->next->next = NULL;
|
||||
nhdr->next->proto = ipv6_ext.ip6e_nxt;
|
||||
|
@ -2571,7 +2571,7 @@ dissect_6lowpan_iphc_nhc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gi
|
|||
#endif
|
||||
|
||||
/* Create the next header structure for the UDP datagram. */
|
||||
length = (gint)tvb_ensure_captured_length_remaining(tvb, offset);
|
||||
length = tvb_captured_length_remaining(tvb, offset);
|
||||
nhdr = (struct lowpan_nhdr *)wmem_alloc(wmem_packet_scope(), sizeof(struct lowpan_nhdr) + sizeof(struct udp_hdr) + length);
|
||||
nhdr->next = NULL;
|
||||
nhdr->proto = IP_PROTO_UDP;
|
||||
|
|
Loading…
Reference in New Issue