#5 Add checks on incoming queries

This commit is contained in:
Erik Ekman 2007-02-04 17:22:07 +00:00
parent 7207d722b4
commit 728919fc9a

View file

@ -284,7 +284,7 @@ dns_decode(char *buf, size_t buflen, struct query *q, qr_t qr, char *packet, siz
readlong(packet, &data, &ttl);
readshort(packet, &data, &rlen);
rv = MIN(rlen, sizeof(rdata));
readdata(packet, &data, rdata, rv);
rv = readdata(packet, &data, rdata, rv);
if(type == T_NULL && rv > 2) {
rv = MIN(rv, buflen);
@ -302,6 +302,11 @@ dns_decode(char *buf, size_t buflen, struct query *q, qr_t qr, char *packet, siz
readshort(packet, &data, &type);
readshort(packet, &data, &class);
if(type != T_NULL) {
rv = 0;
break;
}
strncpy(q->name, name, 257);
q->type = type;
q->id = id;