Skip to content

Commit dd25fd0

Browse files
authored
make fuzz checks more lenient (#133)
1 parent eccf28e commit dd25fd0

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ keywords = ["JSON", "parsing", "deserialization", "iter"]
1515
categories = ["parser-implementations", "parsing"]
1616
homepage = "https://github.com/pydantic/jiter/"
1717
repository = "https://github.com/pydantic/jiter/"
18-
rust-version = "1.73.0"
18+
rust-version = "1.74.0"
1919

2020
[profile.bench]
2121
debug = true

crates/fuzz/fuzz_targets/compare_to_serde.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,13 @@ fn errors_equal(jiter_error: &JiterError, serde_error: &SerdeError, json_data: &
8888
} else if matches!(jiter_error.error_type, JiterJsonErrorType::InvalidUnicodeCodePoint) {
8989
// https://github.com/serde-rs/json/issues/1083
9090
remove_suffix(&jiter_error_str) == remove_suffix(&serde_error_str)
91+
} else if jiter_error_str.starts_with("invalid escape at line")
92+
&& serde_error_str.starts_with("invalid escape at line")
93+
{
94+
// see fuzz failures on #130
95+
true
9196
} else {
92-
return jiter_error_str == serde_error_str;
97+
jiter_error_str == serde_error_str
9398
}
9499
}
95100

crates/jiter/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ paste = "1.0.7"
2929
serde_json = {version = "1.0.87", features = ["preserve_order", "arbitrary_precision", "float_roundtrip"]}
3030
serde = "1.0.147"
3131
pyo3 = { workspace = true, features = ["auto-initialize"] }
32-
codspeed-bencher-compat = "2.3.1"
32+
codspeed-bencher-compat = "2.7.1"
3333

3434
[build-dependencies]
3535
pyo3-build-config = { workspace = true, optional = true }

crates/jiter/tests/main.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,16 @@ fn bad_high_order_string_tail() {
615615
assert_eq!(e.description(&bytes), "invalid unicode code point at line 1 column 5")
616616
}
617617

618+
#[test]
619+
fn invalid_escape_position() {
620+
// from fuzzing on #130
621+
let bytes = br#""con(\u0trol character (\u000.00"#;
622+
let e = JsonValue::parse(bytes, false).unwrap_err();
623+
assert_eq!(e.error_type, JsonErrorType::InvalidEscape);
624+
assert_eq!(e.index, 8);
625+
assert_eq!(e.description(bytes), "invalid escape at line 1 column 9")
626+
}
627+
618628
#[test]
619629
fn simd_string_sizes() {
620630
for i in 0..100 {

0 commit comments

Comments
 (0)