Changeset 7289823 in code


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".

Files:
2 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
  • icb.h

    r8871953 r7289823  
    3030#define ICB_MAXPASSLEN           32
    3131#define ICB_MAXTOPICLEN          160
     32#define ICB_MAXHOSTLEN           40
    3233#define ICB_MTABLEN              50 /* XXX */
    3334
     
    7677        char                     nick[ICB_MAXNICKLEN];
    7778        char                     client[ICB_MAXNICKLEN];
    78         char                     host[MAXHOSTNAMELEN];
     79        char                     host[ICB_MAXHOSTLEN];
    7980        char                     buffer[ICB_MSGSIZE];
    8081        struct event             ev;
Note: See TracChangeset for help on using the changeset viewer.