From 2819368e8c7466046c963f31fe885bbb5b1efc53 Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Wed, 27 Dec 2023 13:26:00 -0800 Subject: [PATCH 1/2] Ipv6RoutingHeader::clear_reserved: fix offsets for Type 2 routing headers --- src/wire/ipv6routing.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wire/ipv6routing.rs b/src/wire/ipv6routing.rs index a4943b715..1e31794be 100644 --- a/src/wire/ipv6routing.rs +++ b/src/wire/ipv6routing.rs @@ -261,10 +261,10 @@ impl + AsMut<[u8]>> Header { match routing_type { Type::Type2 => { + data[2] = 0; + data[3] = 0; data[4] = 0; data[5] = 0; - data[6] = 0; - data[7] = 0; } Type::Rpl => { // Retain the higher order 4 bits of the padding field From 6eccf51643a875b132ec919cd92505665399909c Mon Sep 17 00:00:00 2001 From: Thibaut Vandervelden Date: Tue, 2 Jan 2024 09:54:22 +0100 Subject: [PATCH 2/2] chore(wire/ipv6routing): test vectors initial 0xff Using 0xff filled buffers as test vectors to ensure that the reserved fields are cleared to 0. --- src/wire/ipv6routing.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wire/ipv6routing.rs b/src/wire/ipv6routing.rs index 1e31794be..14a1c5ecd 100644 --- a/src/wire/ipv6routing.rs +++ b/src/wire/ipv6routing.rs @@ -581,17 +581,17 @@ mod test { #[test] fn test_repr_emit() { - let mut bytes = [0u8; 22]; + let mut bytes = [0xFFu8; 22]; let mut header = Header::new_unchecked(&mut bytes[..]); REPR_TYPE2.emit(&mut header); assert_eq!(header.into_inner(), &BYTES_TYPE2[..]); - let mut bytes = [0u8; 38]; + let mut bytes = [0xFFu8; 38]; let mut header = Header::new_unchecked(&mut bytes[..]); REPR_SRH_FULL.emit(&mut header); assert_eq!(header.into_inner(), &BYTES_SRH_FULL[..]); - let mut bytes = [0u8; 14]; + let mut bytes = [0xFFu8; 14]; let mut header = Header::new_unchecked(&mut bytes[..]); REPR_SRH_ELIDED.emit(&mut header); assert_eq!(header.into_inner(), &BYTES_SRH_ELIDED[..]);