diff options
author | Vasil Velichkov <vvvelichkov@gmail.com> | 2018-10-30 00:44:16 +0200 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2018-10-31 02:45:27 +0000 |
commit | 5359a97d4383ca75606b6011006f44b040d5b92b (patch) | |
tree | cfe544c5ab7a7dc32c99684806c81ec34245bf37 /text2pcap.c | |
parent | 25844263107e20b7bd1f3fabebf782456e06dbba (diff) |
text2pcap: Fix -i <proto> when IPv6 (-6) is specified
When the -i <proto> option is specified the hdr_ip was always set to
TRUE which resulted in a wrong header length when the IPv6 (-6) option
is specified as well. To resolve this set hdr_ip only when -i is specified
without -4 or -6 options.
Change-Id: I21898f27ceaad603b9275ab6878ff4bd8f9586cd
Reviewed-on: https://code.wireshark.org/review/30411
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'text2pcap.c')
-rw-r--r-- | text2pcap.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/text2pcap.c b/text2pcap.c index f492059b16..3793ac5295 100644 --- a/text2pcap.c +++ b/text2pcap.c @@ -152,7 +152,7 @@ static guint32 hdr_ethernet_proto = 0; /* Dummy IP header */ static int hdr_ip = FALSE; static int hdr_ipv6 = FALSE; -static long hdr_ip_proto = 0; +static long hdr_ip_proto = -1; /* Destination and source addresses for IP header */ static guint32 hdr_ip_dest_addr = 0; @@ -1512,7 +1512,6 @@ parse_options (int argc, char *argv[]) break; case 'i': - hdr_ip = TRUE; hdr_ip_proto = strtol(optarg, &p, 10); if (p == optarg || *p != '\0' || hdr_ip_proto < 0 || hdr_ip_proto > 255) { @@ -1830,6 +1829,11 @@ parse_options (int argc, char *argv[]) timecode_default = *now_tm; timecode_default.tm_isdst = -1; /* Unknown for now, depends on time given to the strptime() function */ + if (hdr_ip_proto != -1 && !(hdr_ip || hdr_ipv6)) { + /* If -i <proto> option is specified without -4 or -6 then add the default IPv4 header */ + hdr_ip = TRUE; + } + if ((hdr_tcp || hdr_udp || hdr_sctp) && !(hdr_ip || hdr_ipv6)) { /* * If TCP (-T), UDP (-u) or SCTP (-s/-S) header options are specified |