Skip to content

Commit 59acf2c

Browse files
committed
test: draw the clean decode path in the size cap fuzz
1 parent 1f07f73 commit 59acf2c

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎tests/test_fuzz_incoming.py‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import socket
1010

11-
from hypothesis import given
11+
from hypothesis import example, given
1212
from hypothesis import strategies as st
1313

1414
from zeroconf import DNSIncoming, DNSNsec, DNSOutgoing, const
@@ -154,9 +154,12 @@ def test_nsec_bitmap_mutations_never_raise(
154154

155155
@given(
156156
tail_room=st.integers(min_value=0, max_value=32),
157-
rdlength=st.integers(min_value=0, max_value=0xFFFF),
157+
# 8 is the one rdlength that decodes cleanly; draw it regularly so the
158+
# fast path also runs against the cap, not just the record-drop resync
159+
rdlength=st.one_of(st.just(8), st.integers(min_value=0, max_value=0xFFFF)),
158160
pointer_target=st.integers(min_value=0, max_value=0x3FFF),
159161
)
162+
@example(tail_room=0, rdlength=8, pointer_target=0x0C)
160163
def test_records_near_the_size_cap_never_raise(tail_room: int, rdlength: int, pointer_target: int) -> None:
161164
"""Record headers and pointers in the last bytes below 64 KiB cannot wrap the guards."""
162165
tail_record = (
@@ -179,4 +182,6 @@ def test_records_near_the_size_cap_never_raise(tail_room: int, rdlength: int, po
179182
+ tail_record
180183
)
181184
assert len(packet) == total
182-
_parse(packet)
185+
answers = _parse(packet)
186+
if rdlength == 8 and pointer_target == 0x0C:
187+
assert len(answers) == 1

0 commit comments

Comments
 (0)