-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #512 from fitzgen/fuzzing
Add fuzzing infrastructure
- Loading branch information
Showing
12 changed files
with
268 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
target | ||
corpus | ||
artifacts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
[package] | ||
name = "gimli-fuzz" | ||
version = "0.0.0" | ||
authors = ["Automatically generated"] | ||
publish = false | ||
edition = "2018" | ||
|
||
[package.metadata] | ||
cargo-fuzz = true | ||
|
||
[dependencies] | ||
libfuzzer-sys = "0.3" | ||
|
||
[dependencies.gimli] | ||
path = ".." | ||
|
||
# Prevent this from interfering with workspaces | ||
[workspace] | ||
members = ["."] | ||
|
||
[[bin]] | ||
name = "debug_info" | ||
path = "fuzz_targets/debug_info.rs" | ||
|
||
[[bin]] | ||
name = "debug_abbrev" | ||
path = "fuzz_targets/debug_abbrev.rs" | ||
|
||
[[bin]] | ||
name = "debug_line" | ||
path = "fuzz_targets/debug_line.rs" | ||
|
||
[[bin]] | ||
name = "eh_frame" | ||
path = "fuzz_targets/eh_frame.rs" | ||
|
||
[[bin]] | ||
name = "debug_aranges" | ||
path = "fuzz_targets/debug_aranges.rs" | ||
|
||
[[bin]] | ||
name = "eh_frame_hdr" | ||
path = "fuzz_targets/eh_frame_hdr.rs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#![no_main] | ||
|
||
use gimli::{read::DebugAbbrev, DebugAbbrevOffset, LittleEndian}; | ||
use libfuzzer_sys::fuzz_target; | ||
|
||
fuzz_target!(|debug_abbrev: &[u8]| { | ||
let len = debug_abbrev.len(); | ||
let debug_abbrev = DebugAbbrev::new(&debug_abbrev, LittleEndian); | ||
|
||
let offset = DebugAbbrevOffset(0); | ||
if let Ok(abbreviations) = debug_abbrev.abbreviations(offset) { | ||
for i in 1..len { | ||
let _ = abbreviations.get(i as u64); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#![no_main] | ||
|
||
use gimli::{read::DebugAranges, LittleEndian}; | ||
use libfuzzer_sys::fuzz_target; | ||
|
||
fuzz_target!(|debug_aranges: &[u8]| { | ||
let debug_aranges = DebugAranges::new(&debug_aranges, LittleEndian); | ||
let mut items = debug_aranges.items(); | ||
while let Ok(Some(_entry)) = items.next() { | ||
continue; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#![no_main] | ||
|
||
use gimli::{ | ||
read::{DebugAbbrev, DebugInfo}, | ||
LittleEndian, | ||
}; | ||
use libfuzzer_sys::fuzz_target; | ||
|
||
fuzz_target!(|sections: (Vec<u8>, Vec<u8>)| { | ||
let (debug_abbrev, debug_info) = sections; | ||
let debug_abbrev = DebugAbbrev::new(&debug_abbrev, LittleEndian); | ||
let debug_info = DebugInfo::new(&debug_info, LittleEndian); | ||
|
||
let mut units = debug_info.units(); | ||
while let Ok(Some(unit)) = units.next() { | ||
if let Ok(abbrevs) = unit.abbreviations(&debug_abbrev) { | ||
let mut cursor = unit.entries(&abbrevs); | ||
while let Ok(Some((_delta, entry))) = cursor.next_dfs() { | ||
let mut attrs = entry.attrs(); | ||
while let Ok(Some(_attr)) = attrs.next() { | ||
continue; | ||
} | ||
} | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#![no_main] | ||
|
||
use gimli::{read::DebugLine, DebugLineOffset, LittleEndian}; | ||
use libfuzzer_sys::fuzz_target; | ||
|
||
fuzz_target!(|debug_line: &[u8]| { | ||
let debug_line = DebugLine::new(&debug_line, LittleEndian); | ||
|
||
let offset = DebugLineOffset(0); | ||
let address_size = 8; | ||
if let Ok(program) = debug_line.program(offset, address_size, None, None) { | ||
let mut rows = program.rows(); | ||
while let Ok(Some(row)) = rows.next_row() { | ||
let _ = row; | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#![no_main] | ||
|
||
use gimli::{ | ||
read::{BaseAddresses, CieOrFde, EhFrame, UninitializedUnwindContext, UnwindSection}, | ||
LittleEndian, | ||
}; | ||
use libfuzzer_sys::fuzz_target; | ||
|
||
fuzz_target!(|eh_frame: &[u8]| { | ||
let eh_frame = EhFrame::new(&eh_frame, LittleEndian); | ||
|
||
let mut ctx = UninitializedUnwindContext::new(); | ||
let bases = BaseAddresses::default() | ||
.set_eh_frame(0) | ||
.set_eh_frame_hdr(0) | ||
.set_text(0) | ||
.set_got(0); | ||
|
||
let mut entries = eh_frame.entries(&bases); | ||
while let Ok(Some(entry)) = entries.next() { | ||
match entry { | ||
CieOrFde::Cie(_) => continue, | ||
CieOrFde::Fde(partial) => { | ||
if let Ok(fde) = partial.parse(EhFrame::cie_from_offset) { | ||
if let Ok(mut table) = fde.rows(&eh_frame, &bases, &mut ctx) { | ||
while let Ok(Some(_row)) = table.next_row() { | ||
continue; | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#![no_main] | ||
|
||
use gimli::{read::EhFrameHdr, BaseAddresses, LittleEndian}; | ||
use libfuzzer_sys::fuzz_target; | ||
|
||
fuzz_target!(|eh_frame_hdr: &[u8]| { | ||
let eh_frame_hdr = EhFrameHdr::new(eh_frame_hdr, LittleEndian); | ||
let bases = BaseAddresses::default() | ||
.set_eh_frame(0) | ||
.set_eh_frame_hdr(0) | ||
.set_text(0) | ||
.set_got(0); | ||
let address_size = 8; | ||
let _ = eh_frame_hdr.parse(&bases, address_size); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters