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[] = |
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)]) |
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 |
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)); |