Fix SERVFAIL crash on TXT records with valueless keys
zeroconf represents a TXT attribute with no "=" (a bare boolean flag, valid per RFC 6763 §6.4) or an empty value as properties[key] = None. Reconstructing the TXT record blindly did b"%s=%s" % (key, None), which raises TypeError since bytes %-formatting rejects None. The exception propagated out of the deferToThread call and Twisted answered with SERVFAIL instead of the TXT record, silently breaking resolution for any service whose TXT record includes a bare key (e.g. some _rfb._tcp/screen-sharing advertisements). Found by diagnosing a real screen-sharing "impossible de resoudre" failure over a WireGuard-tunneled deployment: dig showed SRV resolving fine but TXT returning SERVFAIL for the same instance, which is why dns-sd -L (needs both) never completed even after flushing the client-side mDNSResponder cache.
This commit is contained in:
@@ -143,7 +143,8 @@ class DynamicResolver(object):
|
|||||||
order.append(kv[0])
|
order.append(kv[0])
|
||||||
i += length
|
i += length
|
||||||
|
|
||||||
data = [b"%s=%s" % (p, info.properties[p]) for p in sorted(info.properties, key=lambda k: order.index(k) if k in order else 1000)]
|
data = [(b"%s=%s" % (p, v)) if (v := info.properties[p]) is not None else p
|
||||||
|
for p in sorted(info.properties, key=lambda k: order.index(k) if k in order else 1000)]
|
||||||
now = current_time_millis()
|
now = current_time_millis()
|
||||||
cached = self.zeroconf.cache.get_by_details(localname, _TYPE_TXT, _CLASS_IN)
|
cached = self.zeroconf.cache.get_by_details(localname, _TYPE_TXT, _CLASS_IN)
|
||||||
record_ttl = int(cached.get_remaining_ttl(now)) if cached else ttl
|
record_ttl = int(cached.get_remaining_ttl(now)) if cached else ttl
|
||||||
|
|||||||
Reference in New Issue
Block a user