Repository navigation
fix(arp): reject bool and non-bytes addresses for non-IP ptypes (#2166) - #2182
Conversation
b22f339 to
0f7af9c
Compare
|
Review: GOOD TO GO at |
|
Coverage: 91.55% (unit tier, Python 3.15,
Per-file detail: the |
|
Ready to merge at
|
Problem: ARP._make_proto_resolve rejected a bool only on the IPv4/IPv6 branches; for any other ptype a bool or int was returned unchanged and make() failed with "TypeError: object of type 'bool' has no len()". ARP._make_addr_resolve had the same gap: a bool or int sha/tha hit the MAC regex as a TypeError for Ethernet, and fell through to len() or a raw struct error for any other htype. Fix: in both resolvers, reject a bool with FieldValueError before the dispatch, keep every str/bytes/bytearray form that already worked, return bytes/bytearray as bytes, and raise ProtocolError for anything else. Test: TestARPNonIPAddressType and TestARPHardwareAddressType in test_arp_proto_addr_length_unit.
|
Rebased onto
Because the patch changed in that docstring, CI has to run again. A short delta review is running. |
0f7af9c to
f7c0c79
Compare
|
Review: GOOD TO GO at |
make testpasses, and a test case covers the changeWhat is the purpose of your pull request?
fix— corrects a defectDescription
Closes #2166.
ARP._make_proto_resolverejected aboolonly on the IPv4/IPv6 branches. For any otherptype, aboolorintcame back unchanged, andmake()failed withTypeError: object of type 'bool' has no len().ARP._make_addr_resolvehas the same gap. On Ethernet a bool or int dies in the MAC regex (TypeError: expected string or bytes-like object). On any otherhtypeit dies withTypeError: … has no len(), and a list dies with a rawstruct.error.boolraisesFieldValueErrorbefore the type dispatch,bytes/bytearraypack asbytes, and anything else raisesProtocolError. Every input that worked onmainstill packs the same octets. TheRaises:sections match.TestARPNonIPAddressTypeandTestARPHardwareAddressTypeintests/protocols/link/test_arp_proto_addr_length_unit.py. The latter includestest_supported_forms_still_pack, which pins the forms that worked onmain. Without the fix, 19 fail.tests/protocols/link/plus the ARP pcapng, short-read round-trip and docstring-contract tests pass (131), as do the project tests that read ARP (38).Raises:block. Whichever merges second needs a docstring-only rebase.