File tree Expand file tree Collapse file tree 5 files changed +53
-6
lines changed Expand file tree Collapse file tree 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"]
1212honggfuzz_fuzz = [" honggfuzz" ]
1313
1414[dependencies ]
15- honggfuzz = { version = " 0.5" , optional = true }
15+ honggfuzz = { version = " 0.5" , default-features = false , optional = true }
1616afl = { version = " 0.3" , optional = true }
1717libc = " 0.2"
1818bech32 = { path = " .." }
Original file line number Diff line number Diff line change 11#! /bin/bash
22set -e
3- cargo install --force honggfuzz
3+ cargo install --force honggfuzz --no-default-features
44for TARGET in fuzz_targets/* ; do
55 FILENAME=$( basename $TARGET )
66 FILE=" ${FILENAME% .* } "
Original file line number Diff line number Diff line change 11extern crate bech32;
22
3- use std:: str :: FromStr ;
3+ use std:: convert :: TryFrom ;
44
55fn do_test ( data : & [ u8 ] ) {
66 if data. len ( ) < 1 {
@@ -19,7 +19,7 @@ fn do_test(data: &[u8]) {
1919
2020 let dp = data[ hrp_end..]
2121 . iter ( )
22- . map ( |b| bech32:: u5:: try_from_u8 ( b % 32 ) . unwrap ( ) )
22+ . map ( |b| bech32:: u5:: try_from ( b % 32 ) . unwrap ( ) )
2323 . collect :: < Vec < _ > > ( ) ;
2424
2525 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> {
415415 return Err ( Error :: InvalidChar ( b as char ) ) ;
416416 }
417417
418- if ( b'a' ..= b'z' ) . contains ( & b ) {
418+ if b . is_ascii_lowercase ( ) {
419419 has_lower = true ;
420- } else if ( b'A' ..= b'Z' ) . contains ( & b ) {
420+ } else if b . is_ascii_uppercase ( ) {
421421 has_upper = true ;
422422 } ;
423423
You can’t perform that action at this time.
0 commit comments