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
name_change/hostname_change can make a first label longer than 63 bytes #549
When a probe finds a conflict, name_change and hostname_change (in src/service_daemon.rs) add (n) or -n to the first label. Neither one checks that the label still fits in 63 bytes. write_name rejects any label longer than MAX_LABEL_BYTES with WriteError::NameTooLong (src/dns_parser.rs), so the renamed name can never be sent.
Example: an instance whose first label is 60 bytes on the wire becomes 64 bytes after name_change adds (2). Every probe and announcement for the new name fails to encode. The service never appears on the network, and the app gets no error.
This was already the case before #547. #547 makes it more likely, because instance names with dots now take the rename path (see #546).
Suggested fix
Shorten the base name so the suffix fits, as mDNSResponder does:
Separate the base from the existing (n) or -n suffix and work out the new suffix. Then cut the base to 63 - suffix.len() bytes as measured on the wire. Recompute this on every rename, because (9) → (10) adds a byte.
Measure wire bytes, not escaped bytes: \. and \\ each count as 1 byte, and any other \x counts as 1 byte plus the length of x, the same way parse_escaped_name counts. Only cut where both of these hold:
not in the middle of an escape pair (cutting \. down to \ would escape the next character);
on a UTF-8 character boundary.
After cutting, trim trailing spaces in name_change (avoids Foo (2)) and a trailing - in hostname_change (avoids foo--2).
Optional: reject a first label over 63 wire bytes in register_service, so the caller gets an error up front instead of a silent failure on the network.
This needs another function that understands the escape rules, alongside parse_escaped_name and split_first_label (#547). It may be worth one shared helper in dns_parser.rs for splitting labels and measuring wire length.
Tests
A 63-byte label is cut to 59 bytes plus (2).
(9) → (10) at the limit, so the base loses one more byte.
A multi-byte UTF-8 character falls right at the cut point.
\. falls right at the cut point, so the whole escape pair is dropped.
Activity
fix: keep renamed first labels within 63 bytes on the wire
fix: keep renamed first labels within 63 bytes on the wire
fix: keep renamed first labels within 63 bytes on the wire
fix: keep renamed first labels within 63 bytes on the wire (keepsimpl…