struct msgreply_entry* e;
verbose(VERB_DETAIL, "reply to query with stored ID %d",
worker->query_id);
- LDNS_ID_SET(ldns_buffer_begin(worker->query_reply.c->buffer),
- worker->query_id);
if(error != 0) {
replyerror(LDNS_RCODE_SERVFAIL, worker);
return 0;
}
+ /* sanity check. */
+ if(!LDNS_QR_WIRE(ldns_buffer_begin(c->buffer)))
+ return 0; /* not a reply. */
+ if(LDNS_OPCODE_WIRE(ldns_buffer_begin(c->buffer)) != LDNS_PACKET_QUERY)
+ return 0; /* not a reply to a query. */
+ if(LDNS_QDCOUNT(ldns_buffer_begin(c->buffer)) > 1)
+ return 0; /* too much in the query section */
/* woohoo a reply! */
rep = (struct reply_info*)malloc(sizeof(struct reply_info));
if(!rep) {
- review of yesterday's commits.
- covered up memory leak of the entry locks.
- answers from the cache correctly. Copies flags correctly.
+ - sanity check for incoming query replies.
22 March 2007: Wouter
- AIX configure check.
ldns_buffer_skip(buffer, 2); /* ID */
flags = ldns_read_uint16(rep->reply);
flags |= (qflags & 0x0100); /* copy RD bit */
- log_info("flags %x", flags);
+ log_assert(flags & 0x8000); /* QR bit must be on in our replies */
ldns_buffer_write_u16(buffer, flags);
ldns_buffer_write(buffer, rep->reply+2, rep->replysize-2);
ldns_buffer_flip(buffer);