localSites icon indicating copy to clipboard operation
localSites copied to clipboard

app crashes when trying to browse to a site advertising a TXT record

Open JensEggers opened this issue 1 year ago • 6 comments

Hi, very handy tool this!

I find that the tool works perfectly as long as there is no data in the TXT record. Any contents at all seem to make it crash when attempting to browse to a site advertising a TXT record.

JensEggers avatar Jun 25 '24 06:06 JensEggers

Hi @JensEggers,

Are you sure it is the TXT record? Because I tried to reproduce the issue and created a _http._tcp service with a TXT record on one of my avahi hosts, and both LocalSites for macOS and iOS have no problem with that.

Actually, testing that I realized all devices I use LocalSites most with actually do have a TXT record called "path", this is a standard way to advertise not just the host, but also the path part of an URL.

LocalSite does check the TXT records and looks for "path". I don't see a bug in that code (SitesMenuController.swift:247 ff) right now, but maybe there's something specific to your TXT records? Could you post an example of a service that makes LocalSites crash?

plan44 avatar Jun 25 '24 10:06 plan44

Hi, it could be that I'm encoding the TXT wrong - I'll fiddle a bit longer and let you know what I find

JensEggers avatar Jun 25 '24 10:06 JensEggers

Are you expecting a certain encoding (eg RFC 6763)?

JensEggers avatar Jun 25 '24 10:06 JensEggers

Hi, it could be that I'm encoding the TXT wrong - I'll fiddle a bit longer and let you know what I find

Ok, but certainly LocalSites should not crash even when encoding is wrong 😉

Are you expecting a certain encoding (eg RFC 6763)?

Looking at the code I see that I expect the value in TXT records to be valid UTF8, however only for the "path" record. The code is not looking at anything other that "path".

plan44 avatar Jun 25 '24 10:06 plan44

Anyway, can you post an example (avahi .service file if you have that, maybe) that generates the crash? I'd like to understand and guard against the crash in any case

plan44 avatar Jun 25 '24 10:06 plan44

Here's a Wireshark record of a packet that will cause LocalSites to crash - but only when clicking on the discovered entry to browse to it. The text record is simply "hello", which is preceded by the normal length fields. It doesn't contain the normally-expected = sign. I was messing around with https://www.npmjs.com/package/multicast-dns trying to get my own information into the TXT record and found the crash.

Now that I'm encoding the TXT properly as name/value pairs LocalSites is holding up just fine 🥇

LocalSites crash.pcapng.zip

JensEggers avatar Jun 25 '24 13:06 JensEggers