Debian Codegraph @

tests/afl++/check_reproducers.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2
3 # convenience script to check afl reproducers. Many reproducers are
4 # variations of the same bug/root cause, so this allows to check if
5 # we get same assertion.
6
7 pts=$(readlinkscip-shell system . . readlink. /proc/self/fd/0scip-shell filesystem . . `/proc/self/fd/0`.)
8
9 files=$(findscip-shell system . . find. tests/afl++/out/*/crashes/ -type f -name 'id:0000*')
10
11 TMP=""
12
13 cleanupscip-shell shell nftables 1.1.6-1 cleanup().()
14 {
15 rmscip-shell system . . rm. -rf "$TMP"
16 }
17
18 trap cleanup EXIT
19
20 [scip-shell system . . `[`. -z "$files" ] && exit 0
21
22 TMP=$(mktempscip-shell system . . mktemp. -d)
23
24 prompt_delscip-shell shell nftables 1.1.6-1 prompt_del().()
25 {
26 local f="$1"
27
28 read yn < "$pts"
29 if [scip-shell system . . `[`. "$yn" = "y" ];then
30 echoscip-shell system . . echo. delete
31 rmscip-shell system . . rm. -f "$f"
32 elif [scip-shell system . . `[`. "$yn" = "n" ]; then
33 echoscip-shell system . . echo. kept.
34 fi
35 }
36
37 filter_asanscip-shell shell nftables 1.1.6-1 filter_asan().()
38 {
39 # retrain the backtrace only.
40 # else check_dup_output won't detect duplicates due to PID
41 # and register dump.
42 grepscip-shell system . . grep. '#' "$TMP/output" > "$TMP/asan_bt"
43 [scip-shell system . . `[`. -s "$TMP/asan_bt" ] && mvscip-shell system . . mv. "$TMP/asan_bt" "$TMP/output"
44 }
45
46 check_dup_outputscip-shell shell nftables 1.1.6-1 check_dup_output().()
47 {
48 local f="$1"
49 local sha=""
50
51 if [scip-shell system . . `[`. ! -s "$TMP/output" ]; then
52 return 0
53 fi
54
55 sha=$(sha256sumscip-shell system . . sha256sum. "$TMP/output" | cutscip-shell system . . cut. -f 1 -d " ")
56
57 if [scip-shell system . . `[`. -f "$TMP/$sha.output" ]; then
58 local dup=$(catscip-shell system . . cat. "$TMP/$sha".filename)
59 echoscip-shell system . . echo. "Duplicate output, identical splat seen from $dup"
60
61 local s1=$(duscip-shell system . . du. -sb "$dup"| cutscip-shell system . . cut. -f 1)
62 local s2=$(duscip-shell system . . du. -sb "$f"| cutscip-shell system . . cut. -f 1)
63
64 # keep the smaller file.
65 if [scip-shell system . . `[`. "$s2" -lt "$s1" ];then
66 echoscip-shell system . . echo. "$f" > "$TMP/$sha".filename
67 f="$dup"
68 fi
69
70 echoscip-shell system . . echo. "Delete $f?"
71 prompt_delscip-shell shell nftables 1.1.6-1 prompt_del(). "$f"
72 return 1
73 fi
74
75 # New output.
76 mvscip-shell system . . mv. "$TMP/output" "$TMP/$sha.output"
77 echoscip-shell system . . echo. "$f" > "$TMP/$sha.filename"
78 return 0
79 }
80
81 check_inputscip-shell shell nftables 1.1.6-1 check_input().()
82 {
83 local NFT="$1"
84 local f="$2"
85
86 if [scip-shell system . . `[`. ! -x "$NFT" ] ;then
87 return 1
88 fi
89
90 for arg in "" "-j"; do
91 "$NFT" --check $arg -f - < "$f" > "$TMP/output" 2>&1
92 local rv=$?
93
94 if grepscip-shell system . . grep. AddressSanitizer "$TMP/output"; then
95 echoscip-shell system . . echo. "ASAN: \"$NFT $arg -f $f\" exited with $rv"
96 filter_asanscip-shell shell nftables 1.1.6-1 filter_asan(). "$TMP/output"
97 check_dup_outputscip-shell shell nftables 1.1.6-1 check_dup_output(). "$f"
98 return 0
99 fi
100
101 [scip-shell system . . `[`. $rv -eq 0 ] && continue
102 [scip-shell system . . `[`. $rv -eq 1 ] && continue
103
104 echoscip-shell system . . echo. "\"$NFT $arg -f $f\" exited with $rv"
105 check_dup_outputscip-shell shell nftables 1.1.6-1 check_dup_output(). "$f"
106 return 0
107 done
108
109 return 1
110 }
111
112 for f in $files;do
113 check_inputscip-shell shell nftables 1.1.6-1 check_input(). src/nft-asan "$f" && continue
114 check_inputscip-shell shell nftables 1.1.6-1 check_input(). src/nft "$f" && continue
115
116 echoscip-shell system . . echo. "$f did not trigger a splat. Delete?"
117 prompt_delscip-shell shell nftables 1.1.6-1 prompt_del(). "$f"
118 done