mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-03-15 15:39:09 +01:00
use hex::decode instead of extend_vec_from_hex
This commit is contained in:
parent
ca6b44b8cc
commit
4c44b787f1
26 changed files with 52 additions and 227 deletions
|
@ -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"
|
||||
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"
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,22 +11,3 @@ macro_rules! test_msg {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[cfg(test)]
|
||||
pub 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,29 +99,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("01", &mut a);
|
||||
super::do_test(&a);
|
||||
super::do_test(&::hex::decode("01").unwrap());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -191,29 +191,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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue