这是indexloc提供的服务,不要输入任何密码
Skip to content

mDNS crash #2703

@blampe

Description

@blampe

Describe the bug

The library seems to crash on certain mDNS datagrams.

Error log

[5/27/2025, 3:06:23 AM] [Apple TV Enhanced] [E] Platform: Error: Unable to execute request G: exception during data handling
Traceback (most recent call last):
  File "/var/lib/homebridge/appletv-enhanced/.venv/lib/python3.12/site-packages/pyatv/core/mdns.py", line 306, in datagram_received
    delegate.datagram_received(data, addr)
  File "/var/lib/homebridge/appletv-enhanced/.venv/lib/python3.12/site-packages/pyatv/core/mdns.py", line 432, in datagram_received
    decoded_msg = DnsMessage().unpack(data)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/lib/homebridge/appletv-enhanced/.venv/lib/python3.12/site-packages/pyatv/support/dns.py", line 377, in unpack
    header = DnsHeader.unpack_read(buffer)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/lib/homebridge/appletv-enhanced/.venv/lib/python3.12/site-packages/pyatv/support/dns.py", line 298, in unpack_read
    return cls._make(unpack_stream(">6H", buffer))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/lib/homebridge/appletv-enhanced/.venv/lib/python3.12/site-packages/pyatv/support/dns.py", line 25, in unpack_stream
    return struct.unpack(fmt, buffer.read(size))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
struct.error: unpack requires a buffer of 12 bytes

How to reproduce the bug?

I'm not sure which DNS entry this is. I've enabled verbose logging and hopefully it will include some more information.

What is expected behavior?

Shouldn't crash.

Operating System

Linux

Python

3.9

pyatv

0.16.0

Device

ATV HD 4th gen tvOS 18

Additional context

Using as part of homebridge-appletv-enhanced.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions