Skyost / Bonsoir

A Zeroconf library that allows you to discover network services and to broadcast your own. Based on Apple Bonjour and Android NSD.
http://bonsoir.skyost.eu/
Other
100 stars 43 forks source link

Discovery fails on iOS 17 #67

Closed szekelyisz closed 7 months ago

szekelyisz commented 7 months ago

Describe the bug Fails to discover services found by the same code on iOS 15.

To Reproduce Steps to reproduce the behavior:

  1. Create a browser
  2. Start discovery

Expected behavior Services discovered the same way as on previous iOS versions

Smartphone (please complete the following information):

Additional context Debug logs:

nw_txt_record_create_with_bytes txt_record cannot have length 0, dumping backtrace:
        [arm64] libnetcore-3762.42.2
    0   Network                             0x00000001b5eef370 __nw_create_backtrace_string + 192
    1   Network                             0x00000001b5fe09ec nw_txt_record_create_with_bytes + 1780
    2   Network                             0x00000001b5fdc548 95F61053-D76D-3530-919D-316D4B349BD6 + 7255368
    3   libsystem_dnssd.dylib               0x000000021ed6a254 FC5FADFF-0991-3401-8C8F-C9F585E203B9 + 4692
    4   libsystem_dnssd.dylib               0x000000021ed6b000 DNSServiceProcessResult + 728
    5   libdispatch.dylib                   0x000000010142ab34 _dispatch_client_callout + 20
    6   libdispatch.dylib                   0x000000010142dc20 _dispatch_continuation_pop + 676
    7   libdispatch.dylib                   0x0000000101445078 _dispatch_source_latch_and_call + 480
    8   libdispatch.dylib                   0x0000000101443acc _dispatch_source_invoke + 860
    9   libdispatch.dylib                   0x0000000101434d6c _dispatch_workloop_invoke + 2336
    10  libdispatch.dylib                   0x00000001014405f8 _dispatch_root_queue_drain_deferred_wlh + 328
    11  libdispatch.dylib                   0x000000010143fc2c _dispatch_workloop_worker_thread + 444
    12  libsystem_pthread.dylib             0x000000021ee1d964 _pthread_wqthread + 288
    13  libsystem_pthread.dylib             0x000000021ee1da04 start_wqthread + 8
Skyost commented 7 months ago

Hey,

Can you provide your Dart code please ? Because I can't reproduce your error, even with empty attributes. Also, which version are you currently using and which version were you previously using ?

szekelyisz commented 7 months ago

Hi. I dug deeper, and it seems like whether the error occurs or not depends on the TXT record returned by the server. The ones that don't trigger the error have at least one zero length field in their TXT. The bad ones don't have any fields. According to RFC 1035 3.3.14, TXT records contain "One or more <character-string>s". So the responses triggering the error are actually invalid. iOS versions before 17 seem to have be permissive and accept the invalid data. So do Android and Avahi. The error message makes sense since the shortest TXT RDATA possible according to the RFC is [00 01 00] (which encodes one zero-length field) is 3 bytes long, so 0 is invalid.