-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix panic due to incorrect ANSI escape handling, add fuzzer (#137)
* Fix subtraction with overflow with malformed ANSI escape * Add fuzzing target * Add assertion to avoid silent overflow * Rename fuzzer
- Loading branch information
Showing
6 changed files
with
361 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
target | ||
corpus | ||
artifacts |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,25 @@ | ||
[package] | ||
name = "prettytable-rs-fuzz" | ||
version = "0.0.0" | ||
authors = ["Automatically generated"] | ||
publish = false | ||
edition = "2018" | ||
|
||
[package.metadata] | ||
cargo-fuzz = true | ||
|
||
[dependencies] | ||
libfuzzer-sys = "0.4" | ||
|
||
[dependencies.prettytable-rs] | ||
path = ".." | ||
|
||
# Prevent this from interfering with workspaces | ||
[workspace] | ||
members = ["."] | ||
|
||
[[bin]] | ||
name = "render" | ||
path = "fuzz_targets/render.rs" | ||
test = false | ||
doc = false |
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,23 @@ | ||
#![no_main] | ||
use libfuzzer_sys::fuzz_target; | ||
|
||
use prettytable::{Table, Row, Cell}; | ||
|
||
use prettytable::format::Alignment::{self, *}; | ||
|
||
fuzz_target!(|data: Vec<Vec<(String, u8)>>| { | ||
fn align_from_u8(x: u8) -> Alignment { | ||
match x { | ||
0 => LEFT, | ||
1 => CENTER, | ||
_ => RIGHT, | ||
} | ||
} | ||
let mut pt = prettytable::Table::new(); | ||
for row in data { | ||
let cells = row.into_iter().map(|x| Cell::new_align(&x.0, align_from_u8(x.1))).collect(); | ||
pt.add_row(Row::new(cells)); | ||
} | ||
|
||
let _ = pt.print(&mut std::io::sink()); | ||
}); |
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
Oops, something went wrong.