Skip to content

Commit 3232a02

Browse files
fix(fuzz): handle all reachable EncodeError arms and remove dead MissingReceiver variant
1 parent 3825c08 commit 3232a02

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

fuzz/fuzz_targets/payload_encode_decode.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,18 @@ fuzz_target!(|data: cesr::fuzzing::Wrapper| {
1111

1212
assert_eq!(data, result.payload);
1313
}
14-
Err(cesr::error::EncodeError::MissingHops) => match &data.0 {
15-
cesr::Payload::RoutedMessage(route, _) => assert!(route.is_empty()),
16-
_ => todo!(),
17-
},
14+
// MissingHops is only raised for RoutedMessage with an empty hop list
15+
Err(cesr::error::EncodeError::MissingHops) => {
16+
assert!(matches!(
17+
&data.0,
18+
cesr::Payload::RoutedMessage(route, _) if route.is_empty()
19+
));
20+
}
21+
// Fields that exceed the CESR variable-data size limit are legitimately rejected
22+
Err(cesr::error::EncodeError::ExcessiveFieldSize) => {}
23+
// Parallel-relation payloads with an empty new_vid are legitimately rejected
1824
Err(cesr::error::EncodeError::InvalidVid) => {}
19-
_ => todo!(),
25+
// Any other error is not expected from encode_payload — surface it as a finding
26+
Err(e) => panic!("unexpected encode error: {e:?}"),
2027
}
2128
});

tsp_sdk/src/cesr/error.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ pub enum EncodeError {
55
ExcessiveFieldSize,
66
#[error("hops field is required but missing")]
77
MissingHops,
8-
#[error("receiver is required but missing")]
9-
MissingReceiver,
108
#[error("VID is not valid for CESR encoding")]
119
InvalidVid,
1210
#[error("invalid signature type")]

0 commit comments

Comments
 (0)