Skip to content

replace use of bitcoin::utils::misc::hex_bytes with hex::decode #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ afl_fuzz = ["afl"]
honggfuzz_fuzz = ["honggfuzz"]

[dependencies]
afl = { version = "0.3", optional = true }
lightning = { path = "..", features = ["fuzztarget"] }
bitcoin = { version = "0.13", features = ["fuzztarget"] }
secp256k1 = { version = "0.9", features=["fuzztarget"] }
rust-crypto = "0.2"
hex = "0.3.2"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think usually its best to just specify 0.3, as minor bumps we'd want to take as bugfixes, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair point!

honggfuzz = { version = "0.5", optional = true }
afl = { version = "0.3", optional = true }
rust-crypto = "0.2"
secp256k1 = { version = "0.9", features=["fuzztarget"] }

[build-dependencies]
cc = "1.0"
Expand Down
21 changes: 2 additions & 19 deletions fuzz/fuzz_targets/chanmon_deser_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,12 @@ fn main() {
}
}

extern crate hex;
#[cfg(test)]
mod tests {
fn extend_vec_from_hex(hex: &str, out: &mut Vec<u8>) {
let mut b = 0;
for (idx, c) in hex.as_bytes().iter().enumerate() {
b <<= 4;
match *c {
b'A'...b'F' => b |= c - b'A' + 10,
b'a'...b'f' => b |= c - b'a' + 10,
b'0'...b'9' => b |= c - b'0',
_ => panic!("Bad hex"),
}
if (idx & 1) == 1 {
out.push(b);
b = 0;
}
}
}

#[test]
fn duplicate_crash() {
let mut a = Vec::new();
extend_vec_from_hex("00", &mut a);
super::do_test(&a);
super::do_test(&::hex::decode("00").unwrap());
}
}
22 changes: 2 additions & 20 deletions fuzz/fuzz_targets/channel_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,29 +333,11 @@ fn main() {
}
}

extern crate hex;
#[cfg(test)]
mod tests {
fn extend_vec_from_hex(hex: &str, out: &mut Vec<u8>) {
let mut b = 0;
for (idx, c) in hex.as_bytes().iter().enumerate() {
b <<= 4;
match *c {
b'A'...b'F' => b |= c - b'A' + 10,
b'a'...b'f' => b |= c - b'a' + 10,
b'0'...b'9' => b |= c - b'0',
_ => panic!("Bad hex"),
}
if (idx & 1) == 1 {
out.push(b);
b = 0;
}
}
}

#[test]
fn duplicate_crash() {
let mut a = Vec::new();
extend_vec_from_hex("00", &mut a);
super::do_test(&a);
super::do_test(&::hex::decode("00").unwrap());
}
}
22 changes: 2 additions & 20 deletions fuzz/fuzz_targets/full_stack_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,29 +368,11 @@ fn main() {
}
}

extern crate hex;
#[cfg(test)]
mod tests {
fn extend_vec_from_hex(hex: &str, out: &mut Vec<u8>) {
let mut b = 0;
for (idx, c) in hex.as_bytes().iter().enumerate() {
b <<= 4;
match *c {
b'A'...b'F' => b |= c - b'A' + 10,
b'a'...b'f' => b |= c - b'a' + 10,
b'0'...b'9' => b |= c - b'0',
_ => panic!("Bad hex"),
}
if (idx & 1) == 1 {
out.push(b);
b = 0;
}
}
}

#[test]
fn duplicate_crash() {
let mut a = Vec::new();
extend_vec_from_hex("00", &mut a);
super::do_test(&a);
super::do_test(&::hex::decode("00").unwrap());
}
}
22 changes: 2 additions & 20 deletions fuzz/fuzz_targets/msg_ping_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,11 @@ fn main() {
}
}

extern crate hex;
#[cfg(test)]
mod tests {
fn extend_vec_from_hex(hex: &str, out: &mut Vec<u8>) {
let mut b = 0;
for (idx, c) in hex.as_bytes().iter().enumerate() {
b <<= 4;
match *c {
b'A'...b'F' => b |= c - b'A' + 10,
b'a'...b'f' => b |= c - b'a' + 10,
b'0'...b'9' => b |= c - b'0',
_ => panic!("Bad hex"),
}
if (idx & 1) == 1 {
out.push(b);
b = 0;
}
}
}

#[test]
fn duplicate_crash() {
let mut a = Vec::new();
extend_vec_from_hex("00", &mut a);
super::do_test(&a);
super::do_test(&::hex::decode("00").unwrap());
}
}
22 changes: 2 additions & 20 deletions fuzz/fuzz_targets/msg_pong_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,11 @@ fn main() {
}
}

extern crate hex;
#[cfg(test)]
mod tests {
fn extend_vec_from_hex(hex: &str, out: &mut Vec<u8>) {
let mut b = 0;
for (idx, c) in hex.as_bytes().iter().enumerate() {
b <<= 4;
match *c {
b'A'...b'F' => b |= c - b'A' + 10,
b'a'...b'f' => b |= c - b'a' + 10,
b'0'...b'9' => b |= c - b'0',
_ => panic!("Bad hex"),
}
if (idx & 1) == 1 {
out.push(b);
b = 0;
}
}
}

#[test]
fn duplicate_crash() {
let mut a = Vec::new();
extend_vec_from_hex("00", &mut a);
super::do_test(&a);
super::do_test(&::hex::decode("00").unwrap());
}
}
6 changes: 2 additions & 4 deletions fuzz/fuzz_targets/msg_targets/msg_accept_channel_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ fn main() {
}
}

extern crate hex;
#[cfg(test)]
mod tests {
use utils::extend_vec_from_hex;
#[test]
fn duplicate_crash() {
let mut a = Vec::new();
extend_vec_from_hex("00", &mut a);
super::do_test(&a);
super::do_test(&::hex::decode("00").unwrap());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ fn main() {
}
}

extern crate hex;
#[cfg(test)]
mod tests {
use utils::extend_vec_from_hex;
#[test]
fn duplicate_crash() {
let mut a = Vec::new();
extend_vec_from_hex("00", &mut a);
super::do_test(&a);
super::do_test(&::hex::decode("00").unwrap());
}
}
6 changes: 2 additions & 4 deletions fuzz/fuzz_targets/msg_targets/msg_closing_signed_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ fn main() {
}
}

extern crate hex;
#[cfg(test)]
mod tests {
use utils::extend_vec_from_hex;
#[test]
fn duplicate_crash() {
let mut a = Vec::new();
extend_vec_from_hex("00", &mut a);
super::do_test(&a);
super::do_test(&::hex::decode("00").unwrap());
}
}
6 changes: 2 additions & 4 deletions fuzz/fuzz_targets/msg_targets/msg_commitment_signed_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ fn main() {
}
}

extern crate hex;
#[cfg(test)]
mod tests {
use utils::extend_vec_from_hex;
#[test]
fn duplicate_crash() {
let mut a = Vec::new();
extend_vec_from_hex("00", &mut a);
super::do_test(&a);
super::do_test(&::hex::decode("00").unwrap());
}
}
6 changes: 2 additions & 4 deletions fuzz/fuzz_targets/msg_targets/msg_error_message_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ fn main() {
}
}

extern crate hex;
#[cfg(test)]
mod tests {
use utils::extend_vec_from_hex;
#[test]
fn duplicate_crash() {
let mut a = Vec::new();
extend_vec_from_hex("00", &mut a);
super::do_test(&a);
super::do_test(&::hex::decode("00").unwrap());
}
}
6 changes: 2 additions & 4 deletions fuzz/fuzz_targets/msg_targets/msg_funding_created_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ fn main() {
}
}

extern crate hex;
#[cfg(test)]
mod tests {
use utils::extend_vec_from_hex;
#[test]
fn duplicate_crash() {
let mut a = Vec::new();
extend_vec_from_hex("00", &mut a);
super::do_test(&a);
super::do_test(&::hex::decode("00").unwrap());
}
}
6 changes: 2 additions & 4 deletions fuzz/fuzz_targets/msg_targets/msg_funding_locked_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ fn main() {
}
}

extern crate hex;
#[cfg(test)]
mod tests {
use utils::extend_vec_from_hex;
#[test]
fn duplicate_crash() {
let mut a = Vec::new();
extend_vec_from_hex("00", &mut a);
super::do_test(&a);
super::do_test(&::hex::decode("00").unwrap());
}
}
6 changes: 2 additions & 4 deletions fuzz/fuzz_targets/msg_targets/msg_funding_signed_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ fn main() {
}
}

extern crate hex;
#[cfg(test)]
mod tests {
use utils::extend_vec_from_hex;
#[test]
fn duplicate_crash() {
let mut a = Vec::new();
extend_vec_from_hex("00", &mut a);
super::do_test(&a);
super::do_test(&::hex::decode("00").unwrap());
}
}
6 changes: 2 additions & 4 deletions fuzz/fuzz_targets/msg_targets/msg_open_channel_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ fn main() {
}
}

extern crate hex;
#[cfg(test)]
mod tests {
use utils::extend_vec_from_hex;
#[test]
fn duplicate_crash() {
let mut a = Vec::new();
extend_vec_from_hex("00", &mut a);
super::do_test(&a);
super::do_test(&::hex::decode("00").unwrap());
}
}
6 changes: 2 additions & 4 deletions fuzz/fuzz_targets/msg_targets/msg_revoke_and_ack_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ fn main() {
}
}

extern crate hex;
#[cfg(test)]
mod tests {
use utils::extend_vec_from_hex;
#[test]
fn duplicate_crash() {
let mut a = Vec::new();
extend_vec_from_hex("00", &mut a);
super::do_test(&a);
super::do_test(&::hex::decode("00").unwrap());
}
}
6 changes: 2 additions & 4 deletions fuzz/fuzz_targets/msg_targets/msg_shutdown_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ fn main() {
}
}

extern crate hex;
#[cfg(test)]
mod tests {
use utils::extend_vec_from_hex;
#[test]
fn duplicate_crash() {
let mut a = Vec::new();
extend_vec_from_hex("00", &mut a);
super::do_test(&a);
super::do_test(&::hex::decode("00").unwrap());
}
}
6 changes: 2 additions & 4 deletions fuzz/fuzz_targets/msg_targets/msg_target_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ fn main() {
}
}

extern crate hex;
#[cfg(test)]
mod tests {
use utils::extend_vec_from_hex;
#[test]
fn duplicate_crash() {
let mut a = Vec::new();
extend_vec_from_hex("00", &mut a);
super::do_test(&a);
super::do_test(&::hex::decode("00").unwrap());
}
}
6 changes: 2 additions & 4 deletions fuzz/fuzz_targets/msg_targets/msg_update_add_htlc_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ fn main() {
}
}

extern crate hex;
#[cfg(test)]
mod tests {
use utils::extend_vec_from_hex;
#[test]
fn duplicate_crash() {
let mut a = Vec::new();
extend_vec_from_hex("00", &mut a);
super::do_test(&a);
super::do_test(&::hex::decode("00").unwrap());
}
}
Loading