The most minimal example:
#[test]
fn de_vec_self() {
use serde_json::json;
use serde_with::{formats::PreferMany, formats::PreferOne, serde_as, OneOrMany};
let json = json!(/* literally anything */);
#[serde_as]
#[derive(Deserialize)]
struct VecSelf(#[serde_as(as = "OneOrMany<_, PreferMany>")] Vec<Self>);
let _: VecSelf = serde_json::from_value(json).unwrap();
}
running 1 test
thread 'de_vec_self' has overflowed its stack
fatal runtime error: stack overflow
I started with an enum which is similar to serde_json::Value, but has more restrictions on what variants are allowed. It turns out you don't even need an enum, a newtype with the as=OneOrMany attr is sufficient to always trigger a stack overflow regardless of the value being parsed.
The most minimal example:
I started with an enum which is similar to
serde_json::Value, but has more restrictions on what variants are allowed. It turns out you don't even need an enum, a newtype with theas=OneOrManyattr is sufficient to always trigger a stack overflow regardless of the value being parsed.