aboutsummaryrefslogtreecommitdiffstats
path: root/text2pcap.c
diff options
context:
space:
mode:
authorJaap Keuter <jaap.keuter@xs4all.nl>2018-11-18 01:25:01 +0100
committerAnders Broman <a.broman58@gmail.com>2018-11-18 07:19:00 +0000
commit93361b9977522070bd41e830965043734f5bb539 (patch)
treee85bee6ff6560ec0226c07c85086bce35f428448 /text2pcap.c
parent7370a6f00f602941e492173164e6d697fd309640 (diff)
text2pcap: assure an IP next layer protocol is set
Using -4 or -6 to set an IP address pair to use in the dummy IP header it is possible to generate a capture in which the next layer protocol is undefined. Add a check that an next layer protocol is always set. Bug: 15275 Change-Id: Ifef54be7f708a0f168d2067f6f691e2611f25428 Signed-off-by: Jaap Keuter <jaap.keuter@xs4all.nl> Reviewed-on: https://code.wireshark.org/review/30683 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, 6 insertions, 0 deletions
diff --git a/text2pcap.c b/text2pcap.c
index a56d2ba87d..108b3e4068 100644
--- a/text2pcap.c
+++ b/text2pcap.c
@@ -1836,6 +1836,12 @@ parse_options (int argc, char *argv[])
hdr_ip = TRUE;
}
+ if (hdr_ip_proto == -1 && (hdr_ip || hdr_ipv6)) {
+ /* if -4 or -6 option is specified without an IP protocol then fail */
+ fprintf(stderr, "IP protocol requires a next layer protocol number\n");
+ return EXIT_FAILURE;
+ }
+
if ((hdr_tcp || hdr_udp || hdr_sctp) && !(hdr_ip || hdr_ipv6)) {
/*
* If TCP (-T), UDP (-u) or SCTP (-s/-S) header options are specified