aboutsummaryrefslogtreecommitdiffstats
path: root/text2pcap.c
diff options
context:
space:
mode:
authorVasil Velichkov <vvvelichkov@gmail.com>2018-10-28 21:46:05 +0200
committerAnders Broman <a.broman58@gmail.com>2018-10-30 15:57:02 +0000
commitb66a76ae84a32f9fbd496e321eb50b186935a1b6 (patch)
treedd30e6543a42794c06074e73fd5882007ed21587 /text2pcap.c
parent9e3d5a7d74c8220c36d849a776822695b61cc8ca (diff)
text2pcap: Fix IPv6 payload length
According to RFC 8200 the payload length must contain the length of the payload without the IPv6 header's length Change-Id: Ibeb18c243edc396eaac6d2ffde73d6c4a6fe75a0 Reviewed-on: https://code.wireshark.org/review/30406 Reviewed-by: Peter Wu <peter@lekensteyn.nl> Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'text2pcap.c')
-rw-r--r--text2pcap.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/text2pcap.c b/text2pcap.c
index 0a189ab8be..f492059b16 100644
--- a/text2pcap.c
+++ b/text2pcap.c
@@ -616,7 +616,6 @@ write_current_packet (gboolean cont)
guint32 length = 0;
guint16 padding_length = 0;
int err;
- guint16 ihatemacros;
gboolean success;
if (curr_offset > header_length) {
@@ -671,7 +670,7 @@ write_current_packet (gboolean cont)
HDR_IPv6.ip6_ctlun.ip6_un2_vfc &= 0x0F;
HDR_IPv6.ip6_ctlun.ip6_un2_vfc |= (6<< 4);
- HDR_IPv6.ip6_ctlun.ip6_un1.ip6_un1_plen = g_htons(length - ip_offset + padding_length);
+ HDR_IPv6.ip6_ctlun.ip6_un1.ip6_un1_plen = g_htons(length - ip_offset - sizeof(HDR_IPv6) + padding_length);
HDR_IPv6.ip6_ctlun.ip6_un1.ip6_un1_nxt = (guint8) hdr_ip_proto;
HDR_IPv6.ip6_ctlun.ip6_un1.ip6_un1_hlim = 32;
write_bytes((const char *)&HDR_IPv6, sizeof(HDR_IPv6));
@@ -681,8 +680,7 @@ write_current_packet (gboolean cont)
pseudoh6.dst_addr6 = HDR_IPv6.ip6_dst;
pseudoh6.zero = 0;
pseudoh6.protocol = (guint8) hdr_ip_proto;
- ihatemacros = g_ntohs(HDR_IPv6.ip6_ctlun.ip6_un1.ip6_un1_plen);
- pseudoh.length = g_htons(length - ihatemacros + sizeof(HDR_UDP));
+ pseudoh.length = g_htons(length - header_length + sizeof(HDR_UDP));
}
if (!hdr_ipv6) {