review: vendor extraction — gate opens; F-1 panic arm fixed

The extraction review against vendor.md's cut table, ADR-011
§Amendment, and AGENTS.md conventions. All five file diffs vs the
fast-socks5 v1.0.0 reference checkout read hunk-by-hunk and
categorized (cut / carried changes / adjustments / provenance /
tests); wasm, clippy, fmt, doc all green; RFC 1928 spot-checks
(reply form, method order, UDP zero fallback, domain cap, FRAG
split) independently verified against the RFC text.

F-1 (critical, resolved here): ReplyError::from_u8 kept upstream's
unreachable!("ReplyError code unsupported.") arm while being
wire-reachable — Socks5Stream::read_request_reply feeds the raw
reply byte from the wire into it, and RFC 1928 §6 marks 0x09-0xFF
unassigned, so a misbehaving peer would panic the consumer task.
Unassigned codes now map to GeneralFailure (the RFC's catch-all),
pinned by a new test, and the panic-translation adjustment is
recorded in vendor.md's adjustment list (with the Config-Default
and write_all notes) in the same change.

Findings F-2..F-4 (dead commented code dropped with its region;
Cargo.toml feature-layout comments; the preserved resolve_dns error
string) reviewed and accepted. Review task file carries the full
record; the gate to the downstream task groups is open.

Verified: cargo test (38 + 32), cargo test --all-features, clippy
--all-targets and --target wasm32-unknown-unknown (-D warnings),
cargo check --target wasm32-unknown-unknown, cargo fmt --check,
cargo doc --no-deps.
This commit is contained in:
glm-5.3-flash committed 2026-09-22 11:01:55 +00:00
1 parent d6fbd04ef3
commit 5b18d4d292
3 files changed
+168 -17

No files matched your search

+20 -1
View File
@@ -224,6 +224,13 @@ impl ReplyError {
}
}
/// Map a wire reply code to its variant. Codes outside the RFC
/// table (`0x09`–`0xFF`, unassigned per RFC 1928 §6) map to
/// `GeneralFailure` — the RFC's catch-all — instead of panicking:
/// the value comes off the wire (the client session feeds the raw
/// reply byte here), so a misbehaving peer must surface as a typed
/// error, never a panic. Upstream's `unreachable!()` arm was the
/// review's F-1 correction.
#[inline]
#[rustfmt::skip]
pub fn from_u8(code: u8) -> ReplyError {
@@ -237,7 +244,7 @@ impl ReplyError {
consts::SOCKS5_REPLY_TTL_EXPIRED => ReplyError::TtlExpired,
consts::SOCKS5_REPLY_COMMAND_NOT_SUPPORTED => ReplyError::CommandNotSupported,
consts::SOCKS5_REPLY_ADDRESS_TYPE_NOT_SUPPORTED => ReplyError::AddressTypeNotSupported,
_ => unreachable!("ReplyError code unsupported."),
_ => ReplyError::GeneralFailure,
}
}
}
@@ -383,6 +390,18 @@ mod tests {
}
}
/// F-1 (review): unassigned reply codes (`0x09`–`0xFF`, RFC 1928
/// §6) surface as `GeneralFailure` — the RFC's catch-all — never
/// a panic. Upstream's `unreachable!()` arm was removed: the code
/// comes off the wire (`read_request_reply` → `from_u8`), so a
/// misbehaving peer must not crash the consumer task.
#[test]
fn reply_error_unassigned_codes_map_to_general_failure() {
for code in [0x09u8, 0x0a, 0x7f, 0xff] {
assert_eq!(ReplyError::from_u8(code).as_u8(), 0x01);
}
}
#[tokio::test]
async fn udp_header_round_trip_ip() {
let target = TargetAddr::Ip("192.168.0.1:80".parse().unwrap());