ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/auth.c
(Generate patch)

Comparing ircd-hybrid/trunk/src/auth.c (file contents):
Revision 8216 by michael, Sun Apr 16 11:44:44 2017 UTC vs.
Revision 8217 by michael, Sun Apr 16 12:19:09 2017 UTC

# Line 62 | Line 62 | enum
62    REPORT_FIN_ID,
63    REPORT_FAIL_ID,
64    REPORT_IP_MISMATCH,
65 <  REPORT_HOST_TOOLONG
65 >  REPORT_HOST_TOOLONG,
66 >  REPORT_HOST_INVALID
67   };
68  
69   static const char *const HeaderMessages[] =
# Line 74 | Line 75 | static const char *const HeaderMessages[
75    [REPORT_FIN_ID] = ":*** Got Ident response",
76    [REPORT_FAIL_ID] = ":*** No Ident response",
77    [REPORT_IP_MISMATCH] = ":*** Your forward and reverse DNS do not match, ignoring hostname",
78 <  [REPORT_HOST_TOOLONG] = ":*** Your hostname is too long, ignoring hostname"
78 >  [REPORT_HOST_TOOLONG] = ":*** Your hostname is too long, ignoring hostname",
79 >  [REPORT_HOST_INVALID] = ":*** Your hostname contains illegal characters, ignoring hostname"
80   };
81  
82   #define sendheader(c, i) sendto_one_notice((c), &me, "%s", HeaderMessages[(i)])
# Line 137 | Line 139 | release_auth_client(struct AuthRequest *
139    read_packet(&client->connection->fd, client);
140   }
141  
142 + static int
143 + auth_verify_hostname(const char *hostname)
144 + {
145 +  const char *p = hostname;
146 +
147 +  assert(p);
148 +
149 +  if (EmptyString(p) || *p == '.' || *p == ':')
150 +    return 0;
151 +
152 +  for (; *p; ++p)
153 +    if (!IsHostChar(*p))
154 +      return 0;
155 +
156 +  return 1;
157 + }
158 +
159   /*
160   * auth_dns_callback - called when resolver query finishes
161   * if the query resulted in a successful search, name will contain
# Line 180 | Line 199 | auth_dns_callback(void *vptr, const stru
199  
200      if (namelength > HOSTLEN)
201        sendheader(auth->client, REPORT_HOST_TOOLONG);
202 +    else if (!auth_verify_hostname(name))
203 +      sendheader(auth->client, REPORT_HOST_INVALID);
204      else
205      {
206        strlcpy(auth->client->host, name, sizeof(auth->client->host));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines