Security fixes

This commit is contained in:
Erik Ekman 2006-09-11 19:07:51 +00:00
parent daae2aa9f0
commit 69c8b05a2c
2 changed files with 7 additions and 6 deletions

11
dns.c
View file

@ -324,8 +324,8 @@ dns_parse_reply(char *outbuf, int buflen, char *packet, int packetlen)
}
if(type == T_NULL && rlen > 2) {
memcpy(outbuf, rdata, rlen);
rv = rlen;
rv = MIN(rlen, sizeof(rdata));
memcpy(outbuf, rdata, rv);
}
}
@ -429,7 +429,7 @@ dnsd_read(int fd, struct query *q, char *buf, int buflen)
short class;
short qdcount;
char *data;
char name[255];
char name[257];
HEADER *header;
socklen_t addrlen;
char packet[64*1024];
@ -449,11 +449,12 @@ dnsd_read(int fd, struct query *q, char *buf, int buflen)
qdcount = ntohs(header->qdcount);
if(qdcount == 1) {
readname(packet, &data, name, sizeof(name));
readname(packet, &data, name, sizeof(name) -1);
name[256] = 0;
readshort(packet, &data, &type);
readshort(packet, &data, &class);
strncpy(q->name, name, 256);
strncpy(q->name, name, 257);
q->type = type;
q->id = id;
q->fromlen = addrlen;

View file

@ -25,7 +25,7 @@ struct packet
};
struct query {
char name[256];
char name[258];
short type;
short id;
struct sockaddr from;