diff options
author | Francois-Xavier Le Bail <fx.lebail@yahoo.com> | 2014-02-15 12:32:44 +0100 |
---|---|---|
committer | Francois-Xavier Le Bail <fx.lebail@yahoo.com> | 2014-02-15 12:36:02 +0100 |
commit | c025e64b9ebbb64b29f3fa58dd88d901b9da9c9d (patch) | |
tree | 537e418fb01f5c701deeb33c1e5821023e4d1063 | |
parent | fc3fcdee62a5820e60a28a6ed75910b207272d03 (diff) | |
download | tcpdump-c025e64b9ebbb64b29f3fa58dd88d901b9da9c9d.tar.gz |
fix partial checksum errors in DCCP decoder, IPv4 case
-rw-r--r-- | ip.h | 2 | ||||
-rw-r--r-- | netdissect.h | 1 | ||||
-rw-r--r-- | print-dccp.c | 4 | ||||
-rw-r--r-- | print-ip.c | 4 | ||||
-rw-r--r-- | print-tcp.c | 4 | ||||
-rw-r--r-- | print-udp.c | 4 | ||||
-rw-r--r-- | tests/TESTLIST | 4 | ||||
-rw-r--r-- | tests/dccp_partial_csum_v4_longer.out | 30 | ||||
-rw-r--r-- | tests/dccp_partial_csum_v4_longer.pcap | bin | 0 -> 1778 bytes | |||
-rw-r--r-- | tests/dccp_partial_csum_v4_simple.out | 14 | ||||
-rw-r--r-- | tests/dccp_partial_csum_v4_simple.pcap | bin | 0 -> 642 bytes |
11 files changed, 57 insertions, 10 deletions
@@ -160,4 +160,4 @@ struct ip_timestamp { #define IP_MSS 576 /* default maximum segment size */ /* in print-ip.c */ -extern int nextproto4_cksum(const struct ip *, const u_int8_t *, u_int, u_int); +extern int nextproto4_cksum(const struct ip *, const u_int8_t *, u_int, u_int, u_int); diff --git a/netdissect.h b/netdissect.h index bdf2ebdb..37bc59e0 100644 --- a/netdissect.h +++ b/netdissect.h @@ -416,7 +416,6 @@ extern void igmp_print(netdissect_options *, register const u_char *, u_int); extern void igrp_print(netdissect_options *,const u_char *, u_int, const u_char *); -extern int nextproto4_cksum(const struct ip *, const u_int8_t *, u_int, u_int); extern void ipN_print(netdissect_options *,const u_char *, u_int); extern void ipx_print(netdissect_options *,const u_char *, u_int); extern void isoclns_print(netdissect_options *,const u_char *, diff --git a/print-dccp.c b/print-dccp.c index 1c354a6a..0d020d65 100644 --- a/print-dccp.c +++ b/print-dccp.c @@ -184,8 +184,8 @@ static inline u_int dccp_csum_coverage(const struct dccp_hdr* dh, u_int len) static int dccp_cksum(const struct ip *ip, const struct dccp_hdr *dh, u_int len) { - return nextproto4_cksum(ip, (const u_int8_t *)(void *)dh, - dccp_csum_coverage(dh, len), IPPROTO_DCCP); + return nextproto4_cksum(ip, (const u_int8_t *)(void *)dh, len, + dccp_csum_coverage(dh, len), IPPROTO_DCCP); } #ifdef INET6 @@ -131,7 +131,7 @@ trunc: */ int nextproto4_cksum(const struct ip *ip, const u_int8_t *data, - u_int len, u_int next_proto) + u_int len, u_int covlen, u_int next_proto) { struct phdr { u_int32_t src; @@ -155,7 +155,7 @@ nextproto4_cksum(const struct ip *ip, const u_int8_t *data, vec[0].ptr = (const u_int8_t *)(void *)&ph; vec[0].len = sizeof(ph); vec[1].ptr = data; - vec[1].len = len; + vec[1].len = covlen; return (in_cksum(vec, 2)); } diff --git a/print-tcp.c b/print-tcp.c index bb76ac7c..eee98fe9 100644 --- a/print-tcp.c +++ b/print-tcp.c @@ -142,8 +142,8 @@ static int tcp_cksum(register const struct ip *ip, register const struct tcphdr *tp, register u_int len) { - return (nextproto4_cksum(ip, (const u_int8_t *)tp, len, - IPPROTO_TCP)); + return nextproto4_cksum(ip, (const u_int8_t *)tp, len, len, + IPPROTO_TCP); } void diff --git a/print-udp.c b/print-udp.c index babdf7c2..a8566d04 100644 --- a/print-udp.c +++ b/print-udp.c @@ -281,8 +281,8 @@ static int udp_cksum(register const struct ip *ip, register const struct udphdr *up, register u_int len) { - return (nextproto4_cksum(ip, (const u_int8_t *)(void *)up, len, - IPPROTO_UDP)); + return nextproto4_cksum(ip, (const u_int8_t *)(void *)up, len, len, + IPPROTO_UDP); } #ifdef INET6 diff --git a/tests/TESTLIST b/tests/TESTLIST index f2ab95b9..4f4d9ea6 100644 --- a/tests/TESTLIST +++ b/tests/TESTLIST @@ -173,3 +173,7 @@ ipv6-bad-version.pcap ipv6-bad-version.pcap ipv6-bad-version.out -t # Loopback/CTP test case loopback loopback.pcap loopback.out -t + +# DCCP partial checksums tests +dccp_partial_csum_v4_simple dccp_partial_csum_v4_simple.pcap dccp_partial_csum_v4_simple.out -t -v +dccp_partial_csum_v4_longer dccp_partial_csum_v4_longer.pcap dccp_partial_csum_v4_longer.out -t -v diff --git a/tests/dccp_partial_csum_v4_longer.out b/tests/dccp_partial_csum_v4_longer.out new file mode 100644 index 00000000..a9b6413a --- /dev/null +++ b/tests/dccp_partial_csum_v4_longer.out @@ -0,0 +1,30 @@ +IP (tos 0x0, ttl 64, id 65312, offset 0, flags [DF], proto DCCP (33), length 52) + 139.133.209.176.39420 > 139.133.209.65.5001: CCVal 0, CsCov 0, cksum 0xaaf3 (correct), request (service=0) +IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto DCCP (33), length 68) + 139.133.209.65.5001 > 139.133.209.176.39420: CCVal 0, CsCov 0, cksum 0xb04b (correct), response (service=0) (ack=38464816766) +IP (tos 0x0, ttl 64, id 65313, offset 0, flags [DF], proto DCCP (33), length 56) + 139.133.209.176.39420 > 139.133.209.65.5001: CCVal 0, CsCov 0, cksum 0xf53a (correct), ack (ack=1960341146) +IP (tos 0x0, ttl 64, id 65314, offset 0, flags [DF], proto DCCP (33), length 152) + 139.133.209.176.39420 > 139.133.209.65.5001: CCVal 0, CsCov 6, cksum 0x7d28 (correct), dataack (ack=1960341146) +IP (tos 0x0, ttl 64, id 3176, offset 0, flags [DF], proto DCCP (33), length 52) + 139.133.209.65.5001 > 139.133.209.176.39420: CCVal 0, CsCov 0, cksum 0xfc63 (correct), ack (ack=38464816768) +IP (tos 0x0, ttl 64, id 65315, offset 0, flags [DF], proto DCCP (33), length 148) + 139.133.209.176.39420 > 139.133.209.65.5001: CCVal 0, CsCov 6, cksum 0x5e05 (correct), dataack (ack=1960341147) +IP (tos 0x0, ttl 64, id 3177, offset 0, flags [DF], proto DCCP (33), length 52) + 139.133.209.65.5001 > 139.133.209.176.39420: CCVal 0, CsCov 0, cksum 0x0165 (correct), ack (ack=38464816769) +IP (tos 0x0, ttl 64, id 65316, offset 0, flags [DF], proto DCCP (33), length 148) + 139.133.209.176.39420 > 139.133.209.65.5001: CCVal 0, CsCov 6, cksum 0x5e1e (correct), dataack (ack=1960341148) +IP (tos 0x0, ttl 64, id 65317, offset 0, flags [DF], proto DCCP (33), length 148) + 139.133.209.176.39420 > 139.133.209.65.5001: CCVal 0, CsCov 6, cksum 0x5e15 (correct), dataack (ack=1960341148) +IP (tos 0x0, ttl 64, id 3178, offset 0, flags [DF], proto DCCP (33), length 56) + 139.133.209.65.5001 > 139.133.209.176.39420: CCVal 0, CsCov 0, cksum 0xfb32 (correct), ack (ack=38464816770) +IP (tos 0x0, ttl 64, id 3179, offset 0, flags [DF], proto DCCP (33), length 56) + 139.133.209.65.5001 > 139.133.209.176.39420: CCVal 0, CsCov 0, cksum 0xfa2f (correct), ack (ack=38464816771) +IP (tos 0x0, ttl 64, id 65318, offset 0, flags [DF], proto DCCP (33), length 148) + 139.133.209.176.39420 > 139.133.209.65.5001: CCVal 0, CsCov 6, cksum 0x5e35 (correct), dataack (ack=1960341150) +IP (tos 0x0, ttl 64, id 65319, offset 0, flags [DF], proto DCCP (33), length 52) + 139.133.209.176.39420 > 139.133.209.65.5001: CCVal 0, CsCov 0, cksum 0xf638 (correct), close (ack=1960341150) +IP (tos 0x0, ttl 64, id 3180, offset 0, flags [DF], proto DCCP (33), length 56) + 139.133.209.65.5001 > 139.133.209.176.39420: CCVal 0, CsCov 0, cksum 0xfb2c (correct), ack (ack=38464816772) +IP (tos 0x0, ttl 64, id 3181, offset 0, flags [DF], proto DCCP (33), length 60) + 139.133.209.65.5001 > 139.133.209.176.39420: CCVal 0, CsCov 0, cksum 0xef25 (correct), reset (code=closed) (ack=38464816773) diff --git a/tests/dccp_partial_csum_v4_longer.pcap b/tests/dccp_partial_csum_v4_longer.pcap Binary files differnew file mode 100644 index 00000000..f1176c03 --- /dev/null +++ b/tests/dccp_partial_csum_v4_longer.pcap diff --git a/tests/dccp_partial_csum_v4_simple.out b/tests/dccp_partial_csum_v4_simple.out new file mode 100644 index 00000000..413ae05a --- /dev/null +++ b/tests/dccp_partial_csum_v4_simple.out @@ -0,0 +1,14 @@ +IP (tos 0x0, ttl 64, id 30095, offset 0, flags [DF], proto DCCP (33), length 52) + 139.133.209.176.52667 > 139.133.209.65.5001: CCVal 0, CsCov 0, cksum 0xa766 (correct), request (service=0) +IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto DCCP (33), length 68) + 139.133.209.65.5001 > 139.133.209.176.52667: CCVal 0, CsCov 0, cksum 0x9a1a (correct), response (service=0) (ack=33164071488) +IP (tos 0x0, ttl 64, id 30096, offset 0, flags [DF], proto DCCP (33), length 56) + 139.133.209.176.52667 > 139.133.209.65.5001: CCVal 0, CsCov 0, cksum 0xdf09 (correct), ack (ack=1925546833) +IP (tos 0x0, ttl 64, id 30097, offset 0, flags [DF], proto DCCP (33), length 68) + 139.133.209.176.52667 > 139.133.209.65.5001: CCVal 0, CsCov 1, cksum 0x9dfa (correct), dataack (ack=1925546833) +IP (tos 0x0, ttl 64, id 24713, offset 0, flags [DF], proto DCCP (33), length 52) + 139.133.209.65.5001 > 139.133.209.176.52667: CCVal 0, CsCov 0, cksum 0xe632 (correct), ack (ack=33164071490) +IP (tos 0x0, ttl 64, id 30098, offset 0, flags [DF], proto DCCP (33), length 52) + 139.133.209.176.52667 > 139.133.209.65.5001: CCVal 0, CsCov 0, cksum 0xdf8d (correct), close (ack=1925546834) +IP (tos 0x0, ttl 64, id 24714, offset 0, flags [DF], proto DCCP (33), length 60) + 139.133.209.65.5001 > 139.133.209.176.52667: CCVal 0, CsCov 0, cksum 0xd900 (correct), reset (code=closed) (ack=33164071491) diff --git a/tests/dccp_partial_csum_v4_simple.pcap b/tests/dccp_partial_csum_v4_simple.pcap Binary files differnew file mode 100644 index 00000000..a9c3d66c --- /dev/null +++ b/tests/dccp_partial_csum_v4_simple.pcap |