#25 Fixed crash on query with bad top domain

This commit is contained in:
Erik Ekman 2007-07-12 08:38:00 +00:00
parent aae94200a5
commit d5ffc25557
2 changed files with 9 additions and 4 deletions

View File

@ -14,6 +14,7 @@ CHANGES:
- All received error messages (RCODE field) are echoed
- Top domain limited to 128 chars
- Case preservation check sent after login to decide codec
- Fixed crash on incoming NULL query in server with bad top domain
2007-03-25: 0.4.0 "Run Home"
- Added multiuser support (up to 8 users simultaneously)

View File

@ -379,10 +379,14 @@ read_dns(int fd, struct query *q, char *buf, int buflen)
if (r > 0) {
dns_decode(buf, buflen, q, QR_QUERY, packet, r);
domain = strstr(q->name, topdomain);
rv = (int) (domain - q->name);
memcpy(buf, q->name, MIN(rv, buflen));
q->fromlen = addrlen;
memcpy((struct sockaddr*)&q->from, (struct sockaddr*)&from, addrlen);
if (domain) {
rv = (int) (domain - q->name);
memcpy(buf, q->name, MIN(rv, buflen));
q->fromlen = addrlen;
memcpy((struct sockaddr*)&q->from, (struct sockaddr*)&from, addrlen);
} else {
rv = 0;
}
} else if (r < 0) {
/* Error */
perror("recvfrom");