File tree 5 files changed +53
-6
lines changed
5 files changed +53
-6
lines changed Original file line number Diff line number Diff line change
1
+ name : Fuzz
2
+
3
+ on : [push, pull_request]
4
+
5
+ jobs :
6
+
7
+ fuzz :
8
+ if : ${{ !github.event.act }}
9
+ runs-on : ubuntu-20.04
10
+ strategy :
11
+ fail-fast : false
12
+ matrix :
13
+ fuzz_target : [decode_rnd, encode_decode]
14
+ steps :
15
+ - name : Install test dependencies
16
+ run : sudo apt-get update -y && sudo apt-get install -y binutils-dev libunwind8-dev libcurl4-openssl-dev libelf-dev libdw-dev cmake gcc libiberty-dev
17
+ - uses : actions/checkout@v2
18
+ - uses : actions/cache@v2
19
+ id : cache-fuzz
20
+ with :
21
+ path : |
22
+ ~/.cargo/bin
23
+ fuzz/target
24
+ target
25
+ key : cache-${{ matrix.target }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}
26
+ - name : Checkout Toolchain
27
+ uses : dtolnay/rust-toolchain@stable
28
+ - name : fuzz
29
+ run : cd fuzz && ./fuzz.sh "${{ matrix.fuzz_target }}"
30
+ - run : echo "${{ matrix.fuzz_target }}.rs" >executed_${{ matrix.fuzz_target }}
31
+ - uses : actions/upload-artifact@v2
32
+ with :
33
+ name : executed_${{ matrix.fuzz_target }}
34
+ path : executed_${{ matrix.fuzz_target }}
35
+
36
+ verify-execution :
37
+ if : ${{ !github.event.act }}
38
+ needs : fuzz
39
+ runs-on : ubuntu-latest
40
+ steps :
41
+ - uses : actions/checkout@v2
42
+ - uses : actions/download-artifact@v2
43
+ - name : Display structure of downloaded files
44
+ run : ls -R
45
+ - run : find executed_* -type f -exec cat {} + | sort > executed
46
+ - run : ls fuzz/fuzz_targets | sort > expected
47
+ - run : diff expected executed
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ afl_fuzz = ["afl"]
12
12
honggfuzz_fuzz = [" honggfuzz" ]
13
13
14
14
[dependencies ]
15
- honggfuzz = { version = " 0.5" , optional = true }
15
+ honggfuzz = { version = " 0.5" , default-features = false , optional = true }
16
16
afl = { version = " 0.3" , optional = true }
17
17
libc = " 0.2"
18
18
bech32 = { path = " .." }
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
set -e
3
- cargo install --force honggfuzz
3
+ cargo install --force honggfuzz --no-default-features
4
4
for TARGET in fuzz_targets/* ; do
5
5
FILENAME=$( basename $TARGET )
6
6
FILE=" ${FILENAME% .* } "
Original file line number Diff line number Diff line change 1
1
extern crate bech32;
2
2
3
- use std:: str :: FromStr ;
3
+ use std:: convert :: TryFrom ;
4
4
5
5
fn do_test ( data : & [ u8 ] ) {
6
6
if data. len ( ) < 1 {
@@ -19,7 +19,7 @@ fn do_test(data: &[u8]) {
19
19
20
20
let dp = data[ hrp_end..]
21
21
. iter ( )
22
- . map ( |b| bech32:: u5:: try_from_u8 ( b % 32 ) . unwrap ( ) )
22
+ . map ( |b| bech32:: u5:: try_from ( b % 32 ) . unwrap ( ) )
23
23
. collect :: < Vec < _ > > ( ) ;
24
24
25
25
let variant = if data[ 0 ] > 0x0f {
Original file line number Diff line number Diff line change @@ -415,9 +415,9 @@ fn check_hrp(hrp: &str) -> Result<Case, Error> {
415
415
return Err ( Error :: InvalidChar ( b as char ) ) ;
416
416
}
417
417
418
- if ( b'a' ..= b'z' ) . contains ( & b ) {
418
+ if b . is_ascii_lowercase ( ) {
419
419
has_lower = true ;
420
- } else if ( b'A' ..= b'Z' ) . contains ( & b ) {
420
+ } else if b . is_ascii_uppercase ( ) {
421
421
has_upper = true ;
422
422
} ;
423
423
You can’t perform that action at this time.
0 commit comments