Skip to content

Commit 0dcbe53

Browse files
committed
test: add unit test for DNS circular compression pointer rejection
Signed-off-by: danbugs <danilochiarlone@gmail.com>
1 parent 55875c1 commit 0dcbe53

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

host/src/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3487,4 +3487,15 @@ mod tests {
34873487
assert_eq!(sock.read_timeout().unwrap(), Some(SOCKET_TIMEOUT));
34883488
assert_eq!(sock.write_timeout().unwrap(), Some(SOCKET_TIMEOUT));
34893489
}
3490+
3491+
#[test]
3492+
fn dns_read_name_rejects_circular_pointer() {
3493+
// Two compression pointers pointing at each other: offset 0 → 2, offset 2 → 0
3494+
let data = [0xC0, 0x02, 0xC0, 0x00];
3495+
let mut pos = 0usize;
3496+
assert!(
3497+
dns_read_name(&data, &mut pos).is_none(),
3498+
"circular DNS compression pointers should be rejected"
3499+
);
3500+
}
34903501
}

0 commit comments

Comments
 (0)