#25 Fixed crash on query with bad top domain

This commit is contained in:
Erik Ekman 2007-07-12 08:38:00 +00:00 committed by Erik Ekman
parent 285a412563
commit f932e57ce6
2 changed files with 9 additions and 4 deletions

View file

@ -14,6 +14,7 @@ CHANGES:
- All received error messages (RCODE field) are echoed - All received error messages (RCODE field) are echoed
- Top domain limited to 128 chars - Top domain limited to 128 chars
- Case preservation check sent after login to decide codec - 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" 2007-03-25: 0.4.0 "Run Home"
- Added multiuser support (up to 8 users simultaneously) - 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) { if (r > 0) {
dns_decode(buf, buflen, q, QR_QUERY, packet, r); dns_decode(buf, buflen, q, QR_QUERY, packet, r);
domain = strstr(q->name, topdomain); domain = strstr(q->name, topdomain);
rv = (int) (domain - q->name); if (domain) {
memcpy(buf, q->name, MIN(rv, buflen)); rv = (int) (domain - q->name);
q->fromlen = addrlen; memcpy(buf, q->name, MIN(rv, buflen));
memcpy((struct sockaddr*)&q->from, (struct sockaddr*)&from, addrlen); q->fromlen = addrlen;
memcpy((struct sockaddr*)&q->from, (struct sockaddr*)&from, addrlen);
} else {
rv = 0;
}
} else if (r < 0) { } else if (r < 0) {
/* Error */ /* Error */
perror("recvfrom"); perror("recvfrom");