Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / regress / sys / net / bpf / out-of-bounds / out-of-bounds.sh
blob6f762a5d8b4abe0c41c65b742e88900cbc33658c
1 #!/bin/sh
3 # an out-of-bounds read in the BPF expression should exit the bpf program,
4 # regardless of other expressions. Pass an expression to tcpdump which
5 # performs an out-of-bound read and ping with a packet which would cause
6 # the expression to succeed if the out-of-bounds read is not handled.
8 # exit status: 0 - pass, 1 - fail, 2 - skip
10 IFACE=${IFACE:-lo0}
11 ADDR=${ADDR:-127.0.0.1}
13 tcpdump -c1 -np -i $IFACE \( link[34000:2]=0 or icmp \) and ip[36:2]=0xcafe > /dev/null &
14 TCPDUMP_PID=$!
16 sleep 1
17 if ! kill -0 $TCPDUMP_PID > /dev/null 2>&1 ; then
18 echo "SKIPPED tcpdump exited - are you root?"; exit 2;
20 if ! ping -c1 -p cafe $ADDR > /dev/null 2>&1 ; then
21 echo "SKIPPED not able to ping localhost";
22 kill $TCPDUMP_PID > /dev/null 2>&1 ; exit 2;
24 sleep 2
25 if ! kill $TCPDUMP_PID > /dev/null 2>&1; then
26 echo "FAILED"; exit 1;
28 wait $TCPDUMP_PID; echo "PASSED"; exit 0;