mirror of https://github.com/getdnsapi/getdns.git
fix: Responses without question RRs (i.e. REFUSED)
This commit is contained in:
parent
55e0d41d4b
commit
432092311e
|
@ -1005,13 +1005,14 @@ priv_getdns_create_reply_question_dict(
|
|||
assert(pkt);
|
||||
assert(q_dict);
|
||||
|
||||
rr = ldns_rr_list_rr(ldns_pkt_question(pkt), 0);
|
||||
if (! rr)
|
||||
return GETDNS_RETURN_GENERIC_ERROR;
|
||||
|
||||
*q_dict = getdns_dict_create_with_context(context);
|
||||
if (! *q_dict)
|
||||
return GETDNS_RETURN_MEMORY_ERROR;
|
||||
|
||||
rr = ldns_rr_list_rr(ldns_pkt_question(pkt), 0);
|
||||
if (! rr)
|
||||
return GETDNS_RETURN_GOOD;
|
||||
|
||||
do { /* break on error (to cleanup *q_dict) */
|
||||
r = getdns_dict_set_int(*q_dict,
|
||||
"qtype", ldns_rr_get_type(rr));
|
||||
|
|
|
@ -476,21 +476,27 @@ create_reply_dict(struct getdns_context *context, getdns_network_req * req,
|
|||
}
|
||||
}
|
||||
|
||||
/* other stuff */
|
||||
/* other stuff
|
||||
* Note that spec doesn't explicitely mention these.
|
||||
* They are only showcased in the response dict example */
|
||||
r = getdns_dict_set_int(result, GETDNS_STR_KEY_ANSWER_TYPE,
|
||||
GETDNS_NAMETYPE_DNS);
|
||||
if (r != GETDNS_RETURN_GOOD) {
|
||||
break;
|
||||
}
|
||||
question = ldns_rr_list_rr(ldns_pkt_question(reply), 0);
|
||||
name = convert_rdf_to_str(ldns_rr_owner(question));
|
||||
if (! name) {
|
||||
r = GETDNS_RETURN_MEMORY_ERROR;
|
||||
break;
|
||||
/* Some packets (like with rcode REFUSED)
|
||||
* don't even have RRs in the question section! */
|
||||
if (question) {
|
||||
name = convert_rdf_to_str(ldns_rr_owner(question));
|
||||
if (! name) {
|
||||
r = GETDNS_RETURN_MEMORY_ERROR;
|
||||
break;
|
||||
}
|
||||
r = getdns_dict_util_set_string(result,
|
||||
GETDNS_STR_KEY_CANONICAL_NM, name);
|
||||
free(name);
|
||||
}
|
||||
r = getdns_dict_util_set_string(result,
|
||||
GETDNS_STR_KEY_CANONICAL_NM, name);
|
||||
free(name);
|
||||
|
||||
} while (0);
|
||||
|
||||
|
|
Loading…
Reference in New Issue