Repository navigation
fix(arp): non-IP protocol addresses pack as ASCII text, and hlen/plen are never checked - #1145
Conversation
… are never checked - _make_proto_resolve takes a str protocol address of a non-IP ptype as the hex string _read_proto_resolve returns, packs it with bytes.fromhex (as #1137 does for hardware addresses), and raises ProtocolError on non-hex. - make() derives hlen/plen from the packed sha/spa when omitted, and raises ProtocolError when any packed address disagrees with its length field, instead of letting the schema truncate it. - test_link_unit pinned 'raw' packing to b'raw'; it now pins hex to octets. Closes #1139
|
Cross-review verdict on
Labelled |
|
Coverage: 88.75% (unit tier, Python 3.14,
Per-file detail: the |
- 22 new 1.5.0 entries for the 30 PRs merged since b10e795 (#1106-#1158), with related fixes grouped per the #918 ruling; three marked breaking to match their labels (#1116, #1138, #1145) - regenerate CHANGELOG.md with util/changelog_md.py - process.rst: entry-count pin re-measured, 167 -> 189 - pep.rst: note the plist round-trip test skipped on the upstream dictdumper fractional-second <date> defect (DictDumper#122) tests/project: conventions_doc_claims, changelog_md and documentation_claims pass; changelog_md.py --check is in step.
make pylint,make mypy,make isort) — ran pylint/isort/mypy onarp.pyonly: no new findings vsmain; not the fullmaketargetsmake testpasses, and a test case covers the change — modules listed below only, not the full suiteWhat is the purpose of your pull request?
fix— corrects a defectCloses #1139. A non-IP
strprotocol address now packs viabytes.fromhex, matching #1137's hardware-address fix, and non-hex input raisesProtocolError.make()deriveshlen/plenfrom the packedsha/spawhen they are omitted. It raisesProtocolErrorwhen any address disagrees with its length field.test_link_unit.pypinned'raw'→b'raw'; it now pins hex → octets.Probe (before → after):
ARP(ptype=0x88B5, plen=2, spa='c000')reads back6330→c000.ARP(hlen=4)truncated silently to 24 bytes →ProtocolError.ARP(ptype=IPv6, spa='::1')wroteplen=4with a truncated address →plen=16, 52 bytes.Tests: in the new
tests/protocols/link/test_arp_proto_addr_length_unit.py, 9 fail without the fix and all pass with it. The 3 that pass either way are the IPv4/IPv6 round-trip and explicit-length guards. All of these pass:test_link_unit24,test_arp_pcapng_hwaddr_octets_unit6,test_layer_placement_unit17,test_rarp_unit1,test_option_roundtrip_unit6,test_generated_pcap_runtime2,test_dispatch_reachability_unit3,tests/project385 (1 skipped).