From: OleksandrKvl Date: Mon, 24 Jun 2019 15:39:35 +0000 (+0300) Subject: pcapparse: Fix handling of TCP payload length X-Git-Tag: 1.19.3~507^2~3188 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=130d096608723dcee48b23f92081687c37c4ff34;p=platform%2Fupstream%2Fgstreamer.git pcapparse: Fix handling of TCP payload length The length of the TCP payload is the IP plus TCP header length subtracted from the IP datagram length specified in the IP header. Prior to this, the size was calculated incorrectly, considering all data after TCP header as a payload till the end of a packet. Fixes #995 --- diff --git a/gst/pcapparse/gstpcapparse.c b/gst/pcapparse/gstpcapparse.c index 0670407..3ea656b 100644 --- a/gst/pcapparse/gstpcapparse.c +++ b/gst/pcapparse/gstpcapparse.c @@ -374,6 +374,7 @@ gst_pcap_parse_scan_frame (GstPcapParse * self, guint16 src_port; guint16 dst_port; guint16 len; + guint16 ip_packet_len; switch (self->linktype) { case LINKTYPE_ETHER: @@ -448,6 +449,7 @@ gst_pcap_parse_scan_frame (GstPcapParse * self, ip_src_addr = *((guint32 *) (buf_ip + 12)); ip_dst_addr = *((guint32 *) (buf_ip + 16)); buf_proto = buf_ip + ip_header_size; + ip_packet_len = GUINT16_FROM_BE (*(guint16 *) (buf_ip + 2)); /* ok for tcp and udp */ src_port = GUINT16_FROM_BE (*((guint16 *) (buf_proto + 0))); @@ -470,7 +472,7 @@ gst_pcap_parse_scan_frame (GstPcapParse * self, /* all remaining data following tcp header is payload */ *payload = buf_proto + len; - *payload_size = self->cur_packet_size - (buf_proto - buf) - len; + *payload_size = ip_packet_len - ip_header_size - len; } /* but still filter as configured */