Skip to content

Commit

Permalink
LTP: Report the data length actually consumed
Browse files Browse the repository at this point in the history
dissect_data_segment dissects both LTP headers and a payload
data segment. It returns the number of bytes consumed and the
length of the payload data segment.

The length of the data segment is subtracted from the number of
bytes consumed to determine the length of the header, which means
that if the packet is cut short, we need to report the length of
data actually present so that we don't call proto_item_set_len
with a negative number.

Fix #19338
  • Loading branch information
johnthacker committed Sep 14, 2023
1 parent b532bf4 commit 2b85103
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions epan/dissectors/packet-ltp.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,14 @@ dissect_data_segment(proto_tree *ltp_tree, tvbuff_t *tvb,packet_info *pinfo,int

if (segment_size >= tvb_captured_length(tvb)) {
/* did not capture the entire packet */
/* XXX: expert info instead? Distinguish between segment_size
* >= reported_length (i.e., bogus reported data_length) and
* too short capture? */
proto_tree_add_string(ltp_data_tree, hf_ltp_partial_packet, tvb, 0, 0, "<increase capture size?>");
/* data_len is subtracted from the return value to set the
* header length, so report the number of data bytes available.
*/
*data_len = tvb_captured_length_remaining(tvb, frame_offset);
return tvb_captured_length(tvb);
}

Expand Down

0 comments on commit 2b85103

Please sign in to comment.