3 # A little script to run tshark on capture file[s] (potentially ones that
4 # failed fuzz testing). Useful because it sets up ulimits and other environment
5 # variables for you to ensure things like misused ephemeral memory are caught.
6 # (I'm writing this after having my machine hang up for like 15 minutes because
7 # I wasn't paying attention while tshark was running on a fuzzed capture and
8 # it used all my RAM + swap--which was pretty painful.)
10 # Copyright 2012 Jeff Morriss <jeff.morriss.ws [AT] gmail.com>
12 # Wireshark - Network traffic analyzer
13 # By Gerald Combs <gerald@wireshark.org>
14 # Copyright 1998 Gerald Combs
16 # This program is free software; you can redistribute it and/or
17 # modify it under the terms of the GNU General Public License
18 # as published by the Free Software Foundation; either version 2
19 # of the License, or (at your option) any later version.
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
26 # You should have received a copy of the GNU General Public License
27 # along with this program; if not, write to the Free Software
28 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31 # shellcheck source=tools/test-common.sh
32 . `dirname $0`/test-common.sh || exit 1
34 # Run under AddressSanitizer ?
35 ASAN=$CONFIGURED_WITH_ASAN
37 while getopts "ab:" OPTCHAR ; do
40 b) WIRESHARK_BIN_DIR=$OPTARG ;;
43 shift $(($OPTIND - 1))
47 printf "Usage: $(basename $0) [-b bin_dir] /path/to/file[s].pcap\n"
52 ws_check_exec "$TSHARK"
54 # Set some limits to the child processes, e.g. stop it if it's running
55 # longer than MAX_CPU_TIME seconds. (ulimit is not supported well on
56 # cygwin - it shows some warnings - and the features we use may not all
57 # be supported on some UN*X platforms.)
58 ulimit -S -t $MAX_CPU_TIME
60 # Allow core files to be generated
63 # Don't enable ulimit -v when using ASAN. See
64 # https://github.com/google/sanitizers/wiki/AddressSanitizer#ulimit--v
65 if [ $ASAN -eq 0 ]; then
66 ulimit -S -v $MAX_VMEM
71 echo "Testing file $file..."
72 echo -n " - with tree... "
73 if $TSHARK -nVxr $file > /dev/null
76 echo -n " - without tree... "
77 if $WIRESHARK_BIN_DIR/tshark -nr $file > /dev/null
80 echo -n " - without tree but with a read filter... "
81 if $WIRESHARK_BIN_DIR/tshark -Yframe -nr $file > /dev/null