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 # SPDX-License-Identifier: GPL-2.0-or-later
19 # shellcheck source=tools/test-common.sh
20 .
"$( dirname "$0" )"/test-common.sh ||
exit 1
22 # Run under AddressSanitizer ?
23 ASAN
=$CONFIGURED_WITH_ASAN
25 while getopts "ab:" OPTCHAR
; do
28 b
) WIRESHARK_BIN_DIR
=$OPTARG ;;
29 *) printf "Unknown option: %s\\n" "$OPTARG"
32 shift $
(( OPTIND
- 1 ))
36 printf "Usage: %s [-b bin_dir] /path/to/file[s].pcap\\n" "$( basename "$0" )"
41 ws_check_exec
"$TSHARK"
43 # Set some limits to the child processes, e.g. stop it if it's running
44 # longer than MAX_CPU_TIME seconds. (ulimit is not supported well on
45 # cygwin - it shows some warnings - and the features we use may not all
46 # be supported on some UN*X platforms.)
47 ulimit -S -t $MAX_CPU_TIME
49 # Allow core files to be generated
52 # Don't enable ulimit -v when using ASAN. See
53 # https://github.com/google/sanitizers/wiki/AddressSanitizer#ulimit--v
54 if [ $ASAN -eq 0 ]; then
55 ulimit -S -v $MAX_VMEM
60 echo "Testing file $file..."
61 echo -n " - with tree... "
62 if $TSHARK -nVxr "$file" > /dev
/null
65 echo -n " - without tree... "
66 if "$WIRESHARK_BIN_DIR/tshark" -nr "$file" > /dev
/null
69 echo -n " - without tree but with a read filter... "
70 if "$WIRESHARK_BIN_DIR/tshark" -Yframe -nr "$file" > /dev
/null