#include "interface.h"
static char name_buffer[MAX_NAME_LEN + 1];
+static char dns_buffer[MAX_NAME_LEN];
static struct blob_buf ans_buf;
const char*
.iov_len = sizeof(h),
},
{
- .iov_base = name_buffer,
+ .iov_base = dns_buffer,
},
{
.iov_base = &q,
q.class = cpu_to_be16(((unicast) ? (CLASS_UNICAST) : (0)) | 1);
q.type = cpu_to_be16(type);
- len = dn_comp(question, (void *) name_buffer, sizeof(name_buffer), NULL, NULL);
+ len = dn_comp(question, (void *) dns_buffer, sizeof(dns_buffer), NULL, NULL);
if (len < 1)
return;
return -1;
}
+ if ((a->class & ~CLASS_FLUSH) != CLASS_IN)
+ return -1;
+
rdata = *b;
if (a->rdlength > *rlen) {
fprintf(stderr, "dropping: bad question\n");
*b += a->rdlength;
if (cache)
- cache_answer(iface, buffer, len, name, a, rdata);
+ cache_answer(iface, buffer, len, name, a, rdata, a->class & CLASS_FLUSH);
return 0;
}
return;
}
+ if (h->questions && !iface->multicast && port != 5353)
+ // silently drop unicast questions that dont originate from port 5353
+ return;
+
while (h->questions-- > 0) {
char *name = dns_consume_name(buffer, len, &b, &rlen);
struct dns_question *q;