Changeset 7289823 in code for dns.c


Ignore:
Timestamp:
Mar 7, 2014, 3:42:03 PM (11 years ago)
Author:
Mike Belopuhov <mike@…>
Branches:
master
Children:
a76f866
Parents:
8871953
Message:

Change DNS resolver to ignore hostnames longer than 39 symbols and
prefer IP/IPv6 addresses instead; substitute "localhost" with
"unknown".

File:
1 edited

Legend:

Unmodified
Added
Removed
  • dns.c

    r8871953 r7289823  
    4343        union {
    4444                struct sockaddr_storage req;
    45                 char                    rep[MAXHOSTNAMELEN];
     45                char                    rep[NI_MAXHOST];
    4646        } u;
    4747};
     
    168168        }
    169169
    170         memcpy(is->host, q.u.rep, MAXHOSTNAMELEN);
    171         is->host[sizeof is->host - 1] = '\0';
     170        if (verbose)
     171                syslog(LOG_DEBUG, "icbd_dns: resolved %s to %s",
     172                    is->host, q.u.rep);
    172173
    173         if (verbose)
    174                 syslog(LOG_DEBUG, "icbd_dns: resolved %s", is->host);
     174        /* XXX */
     175        if (strcmp(q.u.rep, "localhost") == 0)
     176                strlcpy(is->host, "unknown", ICB_MAXHOSTLEN);
     177        else if (strlen(q.u.rep) < ICB_MAXHOSTLEN)
     178                strlcpy(is->host, q.u.rep, ICB_MAXHOSTLEN);
    175179}
    176180
Note: See TracChangeset for help on using the changeset viewer.