You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ip6zone is decoded as a flag protocol: phantom /ip4, broken binary round-trip for zones ≠ 4 bytes #147
multiaddr/codecs/utf8.py (used only by ip6zone) sets SIZE = 0. Elsewhere in the codebase SIZE == 0 means "flag protocol, no value", while variable-length codecs use LENGTH_PREFIXED_VAR_SIZE (-1). bytes_to_string happens to read the length prefix anyway, so str() looks fine, but bytes_iter (and therefore protocols(), items(), split(), Multiaddr(bytes)), string_to_bytes, and MultiAddrItems treat the zone as valueless.
frommultiaddrimportMultiaddrm=Multiaddr("/ip6zone/eth0/ip6/fe80::1/tcp/80")
[p.nameforpinm.protocols()] # ['ip6zone', 'ip4', 'ip6', 'tcp'] <- phantom ip4 ("eth0" read as 101.116.104.48)m.value_for_protocol("ip6zone") # Nonem.split() # BinaryParseErrorMultiaddr(Multiaddr("/ip6zone/en0/ip6/fe80::1").to_bytes()) # BinaryParseError: protocol 3: Unknown ProtocolMultiaddr(Multiaddr("/ip6zone/wlan0/ip6/fe80::1").to_bytes()) # BinaryParseError: protocol 5: Unknown Protocol# "eth0" only works because its length byte 0x04 == P_IP4
multiaddr.transforms.string_to_bytes("/ip6zone/eth0/ip6/fe80::1") drops the zone value entirely (b'*)\xfe\x80...').
Expected
Same as go-multiaddr, where ip6zone is Size: LengthPrefixedVarSize (protocols.go).
Proposed fix
SIZE = LENGTH_PREFIXED_VAR_SIZE in codecs/utf8.py. Locally this makes every case above correct and the existing suite still passes (429 passed, 1 skipped). Would add regression tests for zones of length ≠ 4 (en0, wlan0) covering protocols(), value_for_protocol, split() and the bytes round-trip, and re-enable the commented-out ip6zone cases at tests/test_multiaddr.py:177-178 if they pass.
Activity
fix: decode ip6zone as length-prefixed, not a flag protocol (fixes mu…