Checks returned queries from forwarder source.

git-svn-id: file:///svn/unbound/trunk@193 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards 2007-03-23 13:12:49 +00:00
parent ea25707cb9
commit 2092d6535a
5 changed files with 12 additions and 3 deletions

View file

@ -115,12 +115,17 @@ worker_handle_reply(struct comm_point* c, void* arg, int error,
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) {

View file

@ -2,6 +2,7 @@
- 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.

1
testdata/fwd.rpl vendored
View file

@ -5,6 +5,7 @@ RANGE_BEGIN 0 100
ENTRY_BEGIN
MATCH opcode qtype qname
ADJUST copy_id
REPLY QR RD RA NOERROR
SECTION QUESTION
www.example.com. IN A
SECTION ANSWER

View file

@ -5,6 +5,7 @@ RANGE_BEGIN 0 100
ENTRY_BEGIN
MATCH opcode qtype qname
ADJUST copy_id
REPLY QR RD RA NOERROR
SECTION QUESTION
www.example.net. IN A
SECTION ANSWER
@ -44,6 +45,7 @@ STEP 5 REPLY
ENTRY_BEGIN
MATCH opcode qtype qname
ADJUST copy_id
REPLY QR RD RA NOERROR
SECTION QUESTION
www.example.com. IN A
SECTION ANSWER

View file

@ -173,7 +173,7 @@ void reply_info_answer(struct reply_info* rep, uint16_t qflags,
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);