Skip to content

name_change and hostname_change split on escaped dots, so a conflict rename breaks an instance name with dots #546

Closed

Description

@keepsimple1

When a probe finds a conflict, the conflict handler renames the record with name_change (or hostname_change for A/AAAA). Both take the first label with original.split('.'), which also splits on a dot escaped as \. (RFC 6763 section 4.3). For an instance name with dots, the rename lands in the wrong place:

name_change(r"L\.A\.R\.A Hub._lara._tcp.local.")
  split('.') → ["L\", "A\", "R\", "A Hub", "_lara", "_tcp", "local", ""]
  result:    r"L\ (2).A\.R\.A Hub._lara._tcp.local."
  on the wire: ["L\ (2)", "A.R.A Hub", "_lara", "_tcp", "local"]

The expected result is L\.A\.R\.A Hub (2)._lara._tcp.local..

hostname_change has the same problem: hostname_change(r"my\.host.local.") gives my\-2.host.local. instead of my\.host-2.local..

Impact: after a conflict, the service is announced under a name with an extra label, which is not the instance the app registered. The new name also does not survive a round trip: write_name sends \ as a literal backslash, and a name read back from a packet escapes it as L\\ (2), which does not equal the stored L\ (2). So queries for the renamed instance still go unanswered.

This becomes reachable with #540. Before it, a peer's record name never matched our escaped probe name, so the conflict path never ran for an instance with dots.

Possible fix: find the end of the first label at the first unescaped dot, the way DnsOutPacket::parse_escaped_name does, and keep the rest of the name as it is. Add cases with \. and \\ in the first label to test_name_change and test_hostname_change.

Noticed while reviewing #540.

Activity

  1. added a commit that references this issue on Nov 10, 2026
    2a821c3
  2. added a commit that references this issue on Nov 19, 2026
    ea547cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions