Compare commits
2 commits
9b0a39fa90
...
e27b788e8f
| Author | SHA1 | Date | |
|---|---|---|---|
| e27b788e8f | |||
| 77cbf1700f |
8 changed files with 1606 additions and 5 deletions
4
fuzz/.gitignore
vendored
Normal file
4
fuzz/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
target
|
||||||
|
corpus
|
||||||
|
artifacts
|
||||||
|
coverage
|
||||||
1559
fuzz/Cargo.lock
generated
Normal file
1559
fuzz/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
21
fuzz/Cargo.toml
Normal file
21
fuzz/Cargo.toml
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
[package]
|
||||||
|
name = "fwd-fuzz"
|
||||||
|
version = "0.0.0"
|
||||||
|
publish = false
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[package.metadata]
|
||||||
|
cargo-fuzz = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
libfuzzer-sys = "0.4"
|
||||||
|
|
||||||
|
[dependencies.fwd]
|
||||||
|
path = ".."
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "fuzz_target_1"
|
||||||
|
path = "fuzz_targets/fuzz_target_1.rs"
|
||||||
|
test = false
|
||||||
|
doc = false
|
||||||
|
bench = false
|
||||||
11
fuzz/fuzz_targets/fuzz_target_1.rs
Normal file
11
fuzz/fuzz_targets/fuzz_target_1.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
#![no_main]
|
||||||
|
|
||||||
|
use libfuzzer_sys::fuzz_target;
|
||||||
|
|
||||||
|
extern crate fwd;
|
||||||
|
use fwd::server::refresh::docker::JsonValue;
|
||||||
|
|
||||||
|
fuzz_target!(|data: &[u8]| {
|
||||||
|
// fuzzed code goes here
|
||||||
|
let _ = JsonValue::parse(data);
|
||||||
|
});
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
mod client;
|
mod client;
|
||||||
mod message;
|
mod message;
|
||||||
mod reverse;
|
mod reverse;
|
||||||
mod server;
|
pub mod server;
|
||||||
|
|
||||||
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
pub const REV: &str = env!("REPO_REV");
|
pub const REV: &str = env!("REPO_REV");
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use log::{error, warn};
|
||||||
use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt, BufReader, BufWriter};
|
use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt, BufReader, BufWriter};
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
mod refresh;
|
pub mod refresh;
|
||||||
|
|
||||||
// We drive writes through an mpsc queue, because we not only handle requests
|
// We drive writes through an mpsc queue, because we not only handle requests
|
||||||
// and responses from the client (refresh ports and the like) but also need
|
// and responses from the client (refresh ports and the like) but also need
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ use crate::message::PortDesc;
|
||||||
mod procfs;
|
mod procfs;
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
mod docker;
|
pub mod docker;
|
||||||
|
|
||||||
pub async fn get_entries(_send_anonymous: bool) -> Result<Vec<PortDesc>> {
|
pub async fn get_entries(_send_anonymous: bool) -> Result<Vec<PortDesc>> {
|
||||||
#[cfg_attr(not(target_os = "linux"), allow(unused_mut))]
|
#[cfg_attr(not(target_os = "linux"), allow(unused_mut))]
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ async fn list_containers() -> Result<Vec<u8>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
enum JsonValue {
|
pub enum JsonValue {
|
||||||
Null,
|
Null,
|
||||||
True,
|
True,
|
||||||
False,
|
False,
|
||||||
|
|
@ -207,7 +207,7 @@ impl JsonValue {
|
||||||
}
|
}
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
if i == blob.len() {
|
if i >= blob.len() {
|
||||||
bail!("Unterminated string at {i}");
|
bail!("Unterminated string at {i}");
|
||||||
}
|
}
|
||||||
assert_eq!(blob[i], b'"');
|
assert_eq!(blob[i], b'"');
|
||||||
|
|
@ -874,4 +874,10 @@ mod test {
|
||||||
]);
|
]);
|
||||||
assert_eq!(result, expected);
|
assert_eq!(result, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
pub fn json_decode_unterminated_string_with_escape() {
|
||||||
|
let input = b"\"\\";
|
||||||
|
let _ = JsonValue::parse(input);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue