diff options
| author | 杨威 <[email protected]> | 2018-12-04 02:37:01 +0800 |
|---|---|---|
| committer | 杨威 <[email protected]> | 2018-12-04 02:37:01 +0800 |
| commit | 5427b568de89bcca1bc5a6dcd2a5cf724704a1c3 (patch) | |
| tree | 9edbe5614ce1af20cf0478afbfe70dd2a1e9a575 | |
| parent | 13e7449232df740f18eb58336a29cc3ebd35304d (diff) | |
Update tcpdump.c:835 查找到内层为IPv6时头部地址错误的笔误
| -rw-r--r-- | tcpdump.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -855,11 +855,14 @@ static int MESA_dump_seek_to_inner(char *pkt_buf, int pktlen) if((char *)ip6hdr_greedy == first_ip_layer){ bpf_match_pkt_len = pktlen; /* 最内层和第一层IP一样, 说明是非常标准的ethernet->IPv6包, 且无隧道, 无需memmove操作 */ }else{ - memmove(pkt_buf + sizeof(struct mesa_ethernet_hdr), - ip6hdr_greedy, - pktlen - ((char *)ip6hdr_greedy - pkt_buf)); - bpf_match_pkt_len = pktlen - ((char *)ip4hdr_greedy - pkt_buf) + sizeof(struct mesa_ethernet_hdr); - ehdr->ether_type = htons(ETHERTYPE_IPv6); /* 第一层可能不是IPV6, 比如MPLS, VLAN等,需要改成IP,以便bpf过滤器能正确执行 */ + if(pktlen - ((char *)ip6hdr_greedy - pkt_buf) > 0) + { + memmove(pkt_buf + sizeof(struct mesa_ethernet_hdr), + ip6hdr_greedy, + pktlen - ((char *)ip6hdr_greedy - pkt_buf)); + bpf_match_pkt_len = pktlen - ((char *)ip6hdr_greedy - pkt_buf) + sizeof(struct mesa_ethernet_hdr); + ehdr->ether_type = htons(ETHERTYPE_IPv6); /* 第一层可能不是IPV6, 比如MPLS, VLAN等,需要改成IP,以便bpf过滤器能正确执行 */ + } } if(bpf_match_pkt_len <= 0){ |
