From 5a0aa773c1e5f1102c1a0124554794672eaca931 Mon Sep 17 00:00:00 2001 From: Sontol Bonggol Date: Thu, 10 Aug 2017 23:35:16 -0700 Subject: [PATCH] Do not allow -m option to be larger than our allocated buffer Specifying -m larger than our allocated buffer may result in segfault. This patch protects it from happening and exits early. Change-Id: I2197605d90c98fc9d12b69a68fe533aaf6457df2 Reviewed-on: https://code.wireshark.org/review/23044 Petri-Dish: Alexis La Goutte Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann --- text2pcap.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/text2pcap.c b/text2pcap.c index 3bdd33748f..db23601738 100644 --- a/text2pcap.c +++ b/text2pcap.c @@ -1780,6 +1780,12 @@ parse_options (int argc, char *argv[]) return EXIT_FAILURE; } + if (max_offset > WTAP_MAX_PACKET_SIZE_STANDARD) { + fprintf(stderr, "Maximum packet length cannot be more than %d bytes\n", + WTAP_MAX_PACKET_SIZE_STANDARD); + return EXIT_FAILURE; + } + if (strcmp(argv[optind], "-") != 0) { input_filename = argv[optind]; input_file = ws_fopen(input_filename, "rb");