Skip to content

Commit

Permalink
tinysvcmdns: Only append .local suffix if missing.
Browse files Browse the repository at this point in the history
The .local suffix should only be added to the hostname if it is missing.
It is already present on OS X hosts.

The hostname is never visible by the user, so duplicating the suffix is
not a big issue, but is nevertheless incorrect.
  • Loading branch information
plietar authored and abrasive committed Aug 6, 2014
1 parent 4e32e15 commit 0b31ce4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions mdns_tinysvcmdns.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,13 @@ static int mdns_tinysvcmdns_register(char *apname, int port) {
// according to POSIX, this may be truncated without a final NULL !
hostname[99] = 0;

// will not work on iOS if the hostname doesn't end in .local
strcat(hostname, ".local");
// will not work if the hostname doesn't end in .local
char *hostend = hostname + strlen(hostname);
if ((strlen(hostname) > 6) &&
strcmp(hostend - 6, ".local"))
{
strcat(hostname, ".local");
}

if (getifaddrs(&ifalist) < 0)
{
Expand Down

0 comments on commit 0b31ce4

Please sign in to comment.