mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 13:38:26 +00:00
The dns_message_create() cannot fail, change the return to void
The dns_message_create() function cannot soft fail (as all memory allocations either succeed or cause abort), so we change the function to return void and cleanup the calls.
This commit is contained in:
parent
7deaf9a93c
commit
33eefe9f85
@ -2106,9 +2106,7 @@ setup_lookup(dig_lookup_t *lookup) {
|
|||||||
|
|
||||||
debug("setup_lookup(%p)", lookup);
|
debug("setup_lookup(%p)", lookup);
|
||||||
|
|
||||||
result = dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER,
|
dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &lookup->sendmsg);
|
||||||
&lookup->sendmsg);
|
|
||||||
check_result(result, "dns_message_create");
|
|
||||||
|
|
||||||
if (lookup->new_search) {
|
if (lookup->new_search) {
|
||||||
debug("resetting lookup counter.");
|
debug("resetting lookup counter.");
|
||||||
@ -3776,8 +3774,7 @@ recv_done(isc_task_t *task, isc_event_t *event) {
|
|||||||
goto udp_mismatch;
|
goto udp_mismatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &msg);
|
dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &msg);
|
||||||
check_result(result, "dns_message_create");
|
|
||||||
|
|
||||||
if (tsigkey != NULL) {
|
if (tsigkey != NULL) {
|
||||||
if (l->querysig == NULL) {
|
if (l->querysig == NULL) {
|
||||||
|
@ -350,16 +350,12 @@ nsu_strsep(char **stringp, const char *delim) {
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
reset_system(void) {
|
reset_system(void) {
|
||||||
isc_result_t result;
|
|
||||||
|
|
||||||
ddebug("reset_system()");
|
ddebug("reset_system()");
|
||||||
/* If the update message is still around, destroy it */
|
/* If the update message is still around, destroy it */
|
||||||
if (updatemsg != NULL) {
|
if (updatemsg != NULL) {
|
||||||
dns_message_reset(updatemsg, DNS_MESSAGE_INTENTRENDER);
|
dns_message_reset(updatemsg, DNS_MESSAGE_INTENTRENDER);
|
||||||
} else {
|
} else {
|
||||||
result = dns_message_create(gmctx, DNS_MESSAGE_INTENTRENDER,
|
dns_message_create(gmctx, DNS_MESSAGE_INTENTRENDER, &updatemsg);
|
||||||
&updatemsg);
|
|
||||||
check_result(result, "dns_message_create");
|
|
||||||
}
|
}
|
||||||
updatemsg->opcode = dns_opcode_update;
|
updatemsg->opcode = dns_opcode_update;
|
||||||
if (usegsstsig) {
|
if (usegsstsig) {
|
||||||
@ -2413,8 +2409,7 @@ update_completed(isc_task_t *task, isc_event_t *event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LOCK(&answer_lock);
|
LOCK(&answer_lock);
|
||||||
result = dns_message_create(gmctx, DNS_MESSAGE_INTENTPARSE, &answer);
|
dns_message_create(gmctx, DNS_MESSAGE_INTENTPARSE, &answer);
|
||||||
check_result(result, "dns_message_create");
|
|
||||||
result = dns_request_getresponse(request, answer,
|
result = dns_request_getresponse(request, answer,
|
||||||
DNS_MESSAGEPARSE_PRESERVEORDER);
|
DNS_MESSAGEPARSE_PRESERVEORDER);
|
||||||
switch (result) {
|
switch (result) {
|
||||||
@ -2606,8 +2601,7 @@ recvsoa(isc_task_t *task, isc_event_t *event) {
|
|||||||
reqev = NULL;
|
reqev = NULL;
|
||||||
|
|
||||||
ddebug("About to create rcvmsg");
|
ddebug("About to create rcvmsg");
|
||||||
result = dns_message_create(gmctx, DNS_MESSAGE_INTENTPARSE, &rcvmsg);
|
dns_message_create(gmctx, DNS_MESSAGE_INTENTPARSE, &rcvmsg);
|
||||||
check_result(result, "dns_message_create");
|
|
||||||
result = dns_request_getresponse(request, rcvmsg,
|
result = dns_request_getresponse(request, rcvmsg,
|
||||||
DNS_MESSAGEPARSE_PRESERVEORDER);
|
DNS_MESSAGEPARSE_PRESERVEORDER);
|
||||||
if (result == DNS_R_TSIGERRORSET && servers != NULL) {
|
if (result == DNS_R_TSIGERRORSET && servers != NULL) {
|
||||||
@ -2977,11 +2971,7 @@ start_gssrequest(dns_name_t *master) {
|
|||||||
keyname->attributes |= DNS_NAMEATTR_NOCOMPRESS;
|
keyname->attributes |= DNS_NAMEATTR_NOCOMPRESS;
|
||||||
|
|
||||||
rmsg = NULL;
|
rmsg = NULL;
|
||||||
result = dns_message_create(gmctx, DNS_MESSAGE_INTENTRENDER, &rmsg);
|
dns_message_create(gmctx, DNS_MESSAGE_INTENTRENDER, &rmsg);
|
||||||
if (result != ISC_R_SUCCESS) {
|
|
||||||
fatal("dns_message_create failed: %s",
|
|
||||||
isc_result_totext(result));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Build first request. */
|
/* Build first request. */
|
||||||
context = GSS_C_NO_CONTEXT;
|
context = GSS_C_NO_CONTEXT;
|
||||||
@ -3107,8 +3097,7 @@ recvgss(isc_task_t *task, isc_event_t *event) {
|
|||||||
reqev = NULL;
|
reqev = NULL;
|
||||||
|
|
||||||
ddebug("recvgss creating rcvmsg");
|
ddebug("recvgss creating rcvmsg");
|
||||||
result = dns_message_create(gmctx, DNS_MESSAGE_INTENTPARSE, &rcvmsg);
|
dns_message_create(gmctx, DNS_MESSAGE_INTENTPARSE, &rcvmsg);
|
||||||
check_result(result, "dns_message_create");
|
|
||||||
|
|
||||||
result = dns_request_getresponse(request, rcvmsg,
|
result = dns_request_getresponse(request, rcvmsg,
|
||||||
DNS_MESSAGEPARSE_PRESERVEORDER);
|
DNS_MESSAGEPARSE_PRESERVEORDER);
|
||||||
@ -3233,8 +3222,7 @@ start_update(void) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = dns_message_create(gmctx, DNS_MESSAGE_INTENTRENDER, &soaquery);
|
dns_message_create(gmctx, DNS_MESSAGE_INTENTRENDER, &soaquery);
|
||||||
check_result(result, "dns_message_create");
|
|
||||||
|
|
||||||
if (default_servers) {
|
if (default_servers) {
|
||||||
soaquery->flags |= DNS_MESSAGEFLAG_RD;
|
soaquery->flags |= DNS_MESSAGEFLAG_RD;
|
||||||
|
@ -87,8 +87,7 @@ recvresponse(isc_task_t *task, isc_event_t *event) {
|
|||||||
query = reqev->ev_arg;
|
query = reqev->ev_arg;
|
||||||
|
|
||||||
response = NULL;
|
response = NULL;
|
||||||
result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &response);
|
dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &response);
|
||||||
CHECK("dns_message_create", result);
|
|
||||||
|
|
||||||
result = dns_request_getresponse(reqev->request, response,
|
result = dns_request_getresponse(reqev->request, response,
|
||||||
DNS_MESSAGEPARSE_PRESERVEORDER);
|
DNS_MESSAGEPARSE_PRESERVEORDER);
|
||||||
@ -152,8 +151,7 @@ sendquery(isc_task_t *task) {
|
|||||||
CHECK("dns_name_fromtext", result);
|
CHECK("dns_name_fromtext", result);
|
||||||
|
|
||||||
message = NULL;
|
message = NULL;
|
||||||
result = dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &message);
|
dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &message);
|
||||||
CHECK("dns_message_create", result);
|
|
||||||
|
|
||||||
message->opcode = dns_opcode_query;
|
message->opcode = dns_opcode_query;
|
||||||
message->flags |= DNS_MESSAGEFLAG_RD;
|
message->flags |= DNS_MESSAGEFLAG_RD;
|
||||||
|
@ -88,8 +88,7 @@ recvquery(isc_task_t *task, isc_event_t *event) {
|
|||||||
query = reqev->ev_arg;
|
query = reqev->ev_arg;
|
||||||
|
|
||||||
response = NULL;
|
response = NULL;
|
||||||
result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &response);
|
dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &response);
|
||||||
CHECK("dns_message_create", result);
|
|
||||||
|
|
||||||
result = dns_request_getresponse(reqev->request, response,
|
result = dns_request_getresponse(reqev->request, response,
|
||||||
DNS_MESSAGEPARSE_PRESERVEORDER);
|
DNS_MESSAGEPARSE_PRESERVEORDER);
|
||||||
@ -176,8 +175,7 @@ sendquery(isc_task_t *task, isc_event_t *event) {
|
|||||||
CHECK("dns_tsigkey_create", result);
|
CHECK("dns_tsigkey_create", result);
|
||||||
|
|
||||||
query = NULL;
|
query = NULL;
|
||||||
result = dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &query);
|
dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &query);
|
||||||
CHECK("dns_message_create", result);
|
|
||||||
|
|
||||||
result = dns_tkey_builddhquery(query, ourkey,
|
result = dns_tkey_builddhquery(query, ourkey,
|
||||||
dns_fixedname_name(&ownername),
|
dns_fixedname_name(&ownername),
|
||||||
|
@ -79,8 +79,7 @@ recvquery(isc_task_t *task, isc_event_t *event) {
|
|||||||
query = reqev->ev_arg;
|
query = reqev->ev_arg;
|
||||||
|
|
||||||
response = NULL;
|
response = NULL;
|
||||||
result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &response);
|
dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &response);
|
||||||
CHECK("dns_message_create", result);
|
|
||||||
|
|
||||||
result = dns_request_getresponse(reqev->request, response,
|
result = dns_request_getresponse(reqev->request, response,
|
||||||
DNS_MESSAGEPARSE_PRESERVEORDER);
|
DNS_MESSAGEPARSE_PRESERVEORDER);
|
||||||
@ -121,8 +120,7 @@ sendquery(isc_task_t *task, isc_event_t *event) {
|
|||||||
isc_sockaddr_fromin(&address, &inaddr, port);
|
isc_sockaddr_fromin(&address, &inaddr, port);
|
||||||
|
|
||||||
query = NULL;
|
query = NULL;
|
||||||
result = dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &query);
|
dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &query);
|
||||||
CHECK("dns_message_create", result);
|
|
||||||
|
|
||||||
result = dns_tkey_builddeletequery(query, tsigkey);
|
result = dns_tkey_builddeletequery(query, tsigkey);
|
||||||
CHECK("dns_tkey_builddeletequery", result);
|
CHECK("dns_tkey_builddeletequery", result);
|
||||||
|
@ -277,8 +277,7 @@ process_message(isc_buffer_t *source) {
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
message = NULL;
|
message = NULL;
|
||||||
result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &message);
|
dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &message);
|
||||||
CHECKRESULT(result, "dns_message_create failed");
|
|
||||||
|
|
||||||
result = dns_message_parse(message, source, parseflags);
|
result = dns_message_parse(message, source, parseflags);
|
||||||
if (result == DNS_R_RECOVERABLE) {
|
if (result == DNS_R_RECOVERABLE) {
|
||||||
@ -348,9 +347,7 @@ process_message(isc_buffer_t *source) {
|
|||||||
isc_mem_stats(mctx, stdout);
|
isc_mem_stats(mctx, stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE,
|
dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &message);
|
||||||
&message);
|
|
||||||
CHECKRESULT(result, "dns_message_create failed");
|
|
||||||
|
|
||||||
result = dns_message_parse(message, &buffer, parseflags);
|
result = dns_message_parse(message, &buffer, parseflags);
|
||||||
CHECKRESULT(result, "dns_message_parse failed");
|
CHECKRESULT(result, "dns_message_parse failed");
|
||||||
|
@ -210,8 +210,7 @@ recvresponse(isc_task_t *task, isc_event_t *event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &response);
|
dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &response);
|
||||||
CHECK("dns_message_create", result);
|
|
||||||
|
|
||||||
parseflags |= DNS_MESSAGEPARSE_PRESERVEORDER;
|
parseflags |= DNS_MESSAGEPARSE_PRESERVEORDER;
|
||||||
if (besteffort) {
|
if (besteffort) {
|
||||||
@ -594,8 +593,7 @@ sendquery(struct query *query, isc_task_t *task) {
|
|||||||
CHECK("dns_name_fromtext", result);
|
CHECK("dns_name_fromtext", result);
|
||||||
|
|
||||||
message = NULL;
|
message = NULL;
|
||||||
result = dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &message);
|
dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &message);
|
||||||
CHECK("dns_message_create", result);
|
|
||||||
|
|
||||||
message->opcode = dns_opcode_query;
|
message->opcode = dns_opcode_query;
|
||||||
if (query->recurse) {
|
if (query->recurse) {
|
||||||
|
84
cocci/dns_message_create.spatch
Normal file
84
cocci/dns_message_create.spatch
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
@@
|
||||||
|
statement S;
|
||||||
|
expression V;
|
||||||
|
@@
|
||||||
|
|
||||||
|
- V =
|
||||||
|
dns_message_create(...);
|
||||||
|
- if (V != ISC_R_SUCCESS) S
|
||||||
|
|
||||||
|
@@
|
||||||
|
statement S1, S2;
|
||||||
|
expression V;
|
||||||
|
@@
|
||||||
|
|
||||||
|
- V =
|
||||||
|
dns_message_create(...);
|
||||||
|
- if (V == ISC_R_SUCCESS)
|
||||||
|
S1
|
||||||
|
- else S2
|
||||||
|
|
||||||
|
@@
|
||||||
|
expression V;
|
||||||
|
@@
|
||||||
|
|
||||||
|
- V =
|
||||||
|
dns_message_create(...);
|
||||||
|
- check_result(V, ...);
|
||||||
|
|
||||||
|
@@
|
||||||
|
@@
|
||||||
|
|
||||||
|
- CHECK(
|
||||||
|
dns_message_create(...)
|
||||||
|
- )
|
||||||
|
;
|
||||||
|
|
||||||
|
@@
|
||||||
|
@@
|
||||||
|
|
||||||
|
- DO(...,
|
||||||
|
dns_message_create(...)
|
||||||
|
- )
|
||||||
|
;
|
||||||
|
|
||||||
|
@@
|
||||||
|
@@
|
||||||
|
|
||||||
|
- RETERR(
|
||||||
|
dns_message_create(...)
|
||||||
|
- )
|
||||||
|
;
|
||||||
|
|
||||||
|
@@
|
||||||
|
expression V;
|
||||||
|
@@
|
||||||
|
|
||||||
|
- V =
|
||||||
|
dns_message_create(...);
|
||||||
|
- assert_int_equal(V, ISC_R_SUCCESS);
|
||||||
|
|
||||||
|
@@
|
||||||
|
expression V;
|
||||||
|
@@
|
||||||
|
|
||||||
|
- V =
|
||||||
|
dns_message_create(...);
|
||||||
|
- CHECK(..., V);
|
||||||
|
|
||||||
|
@@
|
||||||
|
expression V;
|
||||||
|
statement S;
|
||||||
|
@@
|
||||||
|
|
||||||
|
- V =
|
||||||
|
dns_message_create(...);
|
||||||
|
- if (ISC_UNLIKELY(V != ISC_R_SUCCESS)) S
|
||||||
|
|
||||||
|
@@
|
||||||
|
expression V;
|
||||||
|
@@
|
||||||
|
|
||||||
|
- V =
|
||||||
|
dns_message_create(...);
|
||||||
|
- RUNTIME_CHECK(V == ISC_R_SUCCESS);
|
@ -47,10 +47,7 @@ parse_message(isc_buffer_t *input, dns_message_t **messagep) {
|
|||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
dns_message_t *message = NULL;
|
dns_message_t *message = NULL;
|
||||||
|
|
||||||
result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &message);
|
dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &message);
|
||||||
if (result != ISC_R_SUCCESS) {
|
|
||||||
return (result);
|
|
||||||
}
|
|
||||||
|
|
||||||
result = dns_message_parse(message, input, DNS_MESSAGEPARSE_BESTEFFORT);
|
result = dns_message_parse(message, input, DNS_MESSAGEPARSE_BESTEFFORT);
|
||||||
if (result == DNS_R_RECOVERABLE) {
|
if (result == DNS_R_RECOVERABLE) {
|
||||||
|
@ -1936,11 +1936,7 @@ update_done(isc_task_t *task, isc_event_t *event) {
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = dns_message_create(client->mctx, DNS_MESSAGE_INTENTPARSE,
|
dns_message_create(client->mctx, DNS_MESSAGE_INTENTPARSE, &answer);
|
||||||
&answer);
|
|
||||||
if (result != ISC_R_SUCCESS) {
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
uctx->state = dns_clientupdatestate_done;
|
uctx->state = dns_clientupdatestate_done;
|
||||||
result = dns_request_getresponse(request, answer,
|
result = dns_request_getresponse(request, answer,
|
||||||
DNS_MESSAGEPARSE_PRESERVEORDER);
|
DNS_MESSAGEPARSE_PRESERVEORDER);
|
||||||
@ -2270,11 +2266,8 @@ receive_soa(isc_task_t *task, isc_event_t *event) {
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = dns_message_create(uctx->client->mctx, DNS_MESSAGE_INTENTPARSE,
|
dns_message_create(uctx->client->mctx, DNS_MESSAGE_INTENTPARSE,
|
||||||
&rcvmsg);
|
&rcvmsg);
|
||||||
if (result != ISC_R_SUCCESS) {
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
result = dns_request_getresponse(request, rcvmsg,
|
result = dns_request_getresponse(request, rcvmsg,
|
||||||
DNS_MESSAGEPARSE_PRESERVEORDER);
|
DNS_MESSAGEPARSE_PRESERVEORDER);
|
||||||
|
|
||||||
@ -2421,12 +2414,8 @@ request_soa(updatectx_t *uctx) {
|
|||||||
unsigned int reqoptions;
|
unsigned int reqoptions;
|
||||||
|
|
||||||
if (soaquery == NULL) {
|
if (soaquery == NULL) {
|
||||||
result = dns_message_create(uctx->client->mctx,
|
dns_message_create(uctx->client->mctx, DNS_MESSAGE_INTENTRENDER,
|
||||||
DNS_MESSAGE_INTENTRENDER,
|
&soaquery);
|
||||||
&soaquery);
|
|
||||||
if (result != ISC_R_SUCCESS) {
|
|
||||||
return (result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
soaquery->flags |= DNS_MESSAGEFLAG_RD;
|
soaquery->flags |= DNS_MESSAGEFLAG_RD;
|
||||||
result = dns_message_gettempname(soaquery, &name);
|
result = dns_message_gettempname(soaquery, &name);
|
||||||
@ -2878,11 +2867,8 @@ dns_client_startupdate(dns_client_t *client, dns_rdataclass_t rdclass,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Make update message */
|
/* Make update message */
|
||||||
result = dns_message_create(client->mctx, DNS_MESSAGE_INTENTRENDER,
|
dns_message_create(client->mctx, DNS_MESSAGE_INTENTRENDER,
|
||||||
&uctx->updatemsg);
|
&uctx->updatemsg);
|
||||||
if (result != ISC_R_SUCCESS) {
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
uctx->updatemsg->opcode = dns_opcode_update;
|
uctx->updatemsg->opcode = dns_opcode_update;
|
||||||
|
|
||||||
if (prerequisites != NULL) {
|
if (prerequisites != NULL) {
|
||||||
|
@ -1143,7 +1143,7 @@ dns_dt_parse(isc_mem_t *mctx, isc_region_t *src, dns_dtdata_t **destp) {
|
|||||||
|
|
||||||
isc_buffer_init(&b, d->msgdata.base, d->msgdata.length);
|
isc_buffer_init(&b, d->msgdata.base, d->msgdata.length);
|
||||||
isc_buffer_add(&b, d->msgdata.length);
|
isc_buffer_add(&b, d->msgdata.length);
|
||||||
CHECK(dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &d->msg));
|
dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &d->msg);
|
||||||
result = dns_message_parse(d->msg, &b, 0);
|
result = dns_message_parse(d->msg, &b, 0);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
if (result != DNS_R_RECOVERABLE) {
|
if (result != DNS_R_RECOVERABLE) {
|
||||||
|
@ -9,8 +9,7 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef DNS_MESSAGE_H
|
#pragma once
|
||||||
#define DNS_MESSAGE_H 1
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
*** Imports
|
*** Imports
|
||||||
@ -203,8 +202,8 @@ struct dns_sortlist_arg {
|
|||||||
|
|
||||||
struct dns_message {
|
struct dns_message {
|
||||||
/* public from here down */
|
/* public from here down */
|
||||||
unsigned int magic;
|
unsigned int magic;
|
||||||
isc_refcount_t refcount;
|
isc_refcount_t refcount;
|
||||||
|
|
||||||
dns_messageid_t id;
|
dns_messageid_t id;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
@ -295,7 +294,7 @@ struct dns_ednsopt {
|
|||||||
|
|
||||||
ISC_LANG_BEGINDECLS
|
ISC_LANG_BEGINDECLS
|
||||||
|
|
||||||
isc_result_t
|
void
|
||||||
dns_message_create(isc_mem_t *mctx, unsigned int intent, dns_message_t **msgp);
|
dns_message_create(isc_mem_t *mctx, unsigned int intent, dns_message_t **msgp);
|
||||||
|
|
||||||
/*%<
|
/*%<
|
||||||
@ -1506,5 +1505,3 @@ dns_message_clonebuffer(dns_message_t *msg);
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
ISC_LANG_ENDDECLS
|
ISC_LANG_ENDDECLS
|
||||||
|
|
||||||
#endif /* DNS_MESSAGE_H */
|
|
||||||
|
@ -714,7 +714,7 @@ spacefortsig(dns_tsigkey_t *key, int otherlen) {
|
|||||||
return (26 + r1.length + r2.length + x + otherlen);
|
return (26 + r1.length + r2.length + x + otherlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_result_t
|
void
|
||||||
dns_message_create(isc_mem_t *mctx, unsigned int intent, dns_message_t **msgp) {
|
dns_message_create(isc_mem_t *mctx, unsigned int intent, dns_message_t **msgp) {
|
||||||
dns_message_t *m;
|
dns_message_t *m;
|
||||||
isc_buffer_t *dynbuf;
|
isc_buffer_t *dynbuf;
|
||||||
@ -728,11 +728,6 @@ dns_message_create(isc_mem_t *mctx, unsigned int intent, dns_message_t **msgp) {
|
|||||||
|
|
||||||
m = isc_mem_get(mctx, sizeof(dns_message_t));
|
m = isc_mem_get(mctx, sizeof(dns_message_t));
|
||||||
|
|
||||||
/*
|
|
||||||
* No allocations until further notice. Just initialize all lists
|
|
||||||
* and other members that are freed in the cleanup phase here.
|
|
||||||
*/
|
|
||||||
|
|
||||||
m->magic = DNS_MESSAGE_MAGIC;
|
m->magic = DNS_MESSAGE_MAGIC;
|
||||||
m->from_to_wire = intent;
|
m->from_to_wire = intent;
|
||||||
msginit(m);
|
msginit(m);
|
||||||
@ -754,10 +749,6 @@ dns_message_create(isc_mem_t *mctx, unsigned int intent, dns_message_t **msgp) {
|
|||||||
ISC_LIST_INIT(m->freerdata);
|
ISC_LIST_INIT(m->freerdata);
|
||||||
ISC_LIST_INIT(m->freerdatalist);
|
ISC_LIST_INIT(m->freerdatalist);
|
||||||
|
|
||||||
/*
|
|
||||||
* Ok, it is safe to allocate (and then "goto cleanup" if failure)
|
|
||||||
*/
|
|
||||||
|
|
||||||
isc_mempool_create(m->mctx, sizeof(dns_name_t), &m->namepool);
|
isc_mempool_create(m->mctx, sizeof(dns_name_t), &m->namepool);
|
||||||
isc_mempool_setfillcount(m->namepool, NAME_COUNT);
|
isc_mempool_setfillcount(m->namepool, NAME_COUNT);
|
||||||
isc_mempool_setfreemax(m->namepool, NAME_COUNT);
|
isc_mempool_setfreemax(m->namepool, NAME_COUNT);
|
||||||
@ -777,7 +768,6 @@ dns_message_create(isc_mem_t *mctx, unsigned int intent, dns_message_t **msgp) {
|
|||||||
isc_refcount_init(&m->refcount, 1);
|
isc_refcount_init(&m->refcount, 1);
|
||||||
|
|
||||||
*msgp = m;
|
*msgp = m;
|
||||||
return (ISC_R_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -2020,8 +2020,8 @@ fctx_query(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo,
|
|||||||
|
|
||||||
query = isc_mem_get(fctx->mctx, sizeof(*query));
|
query = isc_mem_get(fctx->mctx, sizeof(*query));
|
||||||
query->rmessage = NULL;
|
query->rmessage = NULL;
|
||||||
result = dns_message_create(fctx->mctx, DNS_MESSAGE_INTENTPARSE,
|
dns_message_create(fctx->mctx, DNS_MESSAGE_INTENTPARSE,
|
||||||
&query->rmessage);
|
&query->rmessage);
|
||||||
query->mctx = fctx->mctx;
|
query->mctx = fctx->mctx;
|
||||||
query->options = options;
|
query->options = options;
|
||||||
query->attributes = 0;
|
query->attributes = 0;
|
||||||
@ -5130,12 +5130,7 @@ fctx_create(dns_resolver_t *res, const dns_name_t *name, dns_rdatatype_t type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
fctx->qmessage = NULL;
|
fctx->qmessage = NULL;
|
||||||
result = dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER,
|
dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &fctx->qmessage);
|
||||||
&fctx->qmessage);
|
|
||||||
|
|
||||||
if (result != ISC_R_SUCCESS) {
|
|
||||||
goto cleanup_fcount;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Compute an expiration time for the entire fetch.
|
* Compute an expiration time for the entire fetch.
|
||||||
|
@ -209,8 +209,7 @@ render(isc_buffer_t *buf, unsigned flags, dns_tsigkey_t *key,
|
|||||||
dns_compress_t cctx;
|
dns_compress_t cctx;
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
result = dns_message_create(dt_mctx, DNS_MESSAGE_INTENTRENDER, &msg);
|
dns_message_create(dt_mctx, DNS_MESSAGE_INTENTRENDER, &msg);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
assert_non_null(msg);
|
assert_non_null(msg);
|
||||||
|
|
||||||
msg->id = 50;
|
msg->id = 50;
|
||||||
@ -322,8 +321,7 @@ tsig_tcp_test(void **state) {
|
|||||||
/*
|
/*
|
||||||
* Process response message 1.
|
* Process response message 1.
|
||||||
*/
|
*/
|
||||||
result = dns_message_create(dt_mctx, DNS_MESSAGE_INTENTPARSE, &msg);
|
dns_message_create(dt_mctx, DNS_MESSAGE_INTENTPARSE, &msg);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
assert_non_null(msg);
|
assert_non_null(msg);
|
||||||
|
|
||||||
result = dns_message_settsigkey(msg, key);
|
result = dns_message_settsigkey(msg, key);
|
||||||
@ -377,8 +375,7 @@ tsig_tcp_test(void **state) {
|
|||||||
/*
|
/*
|
||||||
* Process response message 2.
|
* Process response message 2.
|
||||||
*/
|
*/
|
||||||
result = dns_message_create(dt_mctx, DNS_MESSAGE_INTENTPARSE, &msg);
|
dns_message_create(dt_mctx, DNS_MESSAGE_INTENTPARSE, &msg);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
assert_non_null(msg);
|
assert_non_null(msg);
|
||||||
|
|
||||||
msg->tcp_continuation = 1;
|
msg->tcp_continuation = 1;
|
||||||
@ -424,8 +421,7 @@ tsig_tcp_test(void **state) {
|
|||||||
/*
|
/*
|
||||||
* Process response message 3.
|
* Process response message 3.
|
||||||
*/
|
*/
|
||||||
result = dns_message_create(dt_mctx, DNS_MESSAGE_INTENTPARSE, &msg);
|
dns_message_create(dt_mctx, DNS_MESSAGE_INTENTPARSE, &msg);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
assert_non_null(msg);
|
assert_non_null(msg);
|
||||||
|
|
||||||
msg->tcp_continuation = 1;
|
msg->tcp_continuation = 1;
|
||||||
|
@ -1104,7 +1104,7 @@ xfrin_send_request(dns_xfrin_ctx_t *xfr) {
|
|||||||
dns_name_t *msgsoaname = NULL;
|
dns_name_t *msgsoaname = NULL;
|
||||||
|
|
||||||
/* Create the request message */
|
/* Create the request message */
|
||||||
CHECK(dns_message_create(xfr->mctx, DNS_MESSAGE_INTENTRENDER, &msg));
|
dns_message_create(xfr->mctx, DNS_MESSAGE_INTENTRENDER, &msg);
|
||||||
CHECK(dns_message_settsigkey(msg, xfr->tsigkey));
|
CHECK(dns_message_settsigkey(msg, xfr->tsigkey));
|
||||||
|
|
||||||
/* Create a name for the question section. */
|
/* Create a name for the question section. */
|
||||||
@ -1254,7 +1254,7 @@ xfrin_recv_done(isc_task_t *task, isc_event_t *ev) {
|
|||||||
|
|
||||||
CHECK(isc_timer_touch(xfr->timer));
|
CHECK(isc_timer_touch(xfr->timer));
|
||||||
|
|
||||||
CHECK(dns_message_create(xfr->mctx, DNS_MESSAGE_INTENTPARSE, &msg));
|
dns_message_create(xfr->mctx, DNS_MESSAGE_INTENTPARSE, &msg);
|
||||||
|
|
||||||
CHECK(dns_message_settsigkey(msg, xfr->tsigkey));
|
CHECK(dns_message_settsigkey(msg, xfr->tsigkey));
|
||||||
CHECK(dns_message_setquerytsig(msg, xfr->lasttsig));
|
CHECK(dns_message_setquerytsig(msg, xfr->lasttsig));
|
||||||
|
@ -12639,10 +12639,7 @@ stub_callback(isc_task_t *task, isc_event_t *event) {
|
|||||||
goto next_master;
|
goto next_master;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = dns_message_create(zone->mctx, DNS_MESSAGE_INTENTPARSE, &msg);
|
dns_message_create(zone->mctx, DNS_MESSAGE_INTENTPARSE, &msg);
|
||||||
if (result != ISC_R_SUCCESS) {
|
|
||||||
goto next_master;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = dns_request_getresponse(revent->request, msg, 0);
|
result = dns_request_getresponse(revent->request, msg, 0);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
@ -13044,10 +13041,7 @@ refresh_callback(isc_task_t *task, isc_event_t *event) {
|
|||||||
goto next_master;
|
goto next_master;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = dns_message_create(zone->mctx, DNS_MESSAGE_INTENTPARSE, &msg);
|
dns_message_create(zone->mctx, DNS_MESSAGE_INTENTPARSE, &msg);
|
||||||
if (result != ISC_R_SUCCESS) {
|
|
||||||
goto next_master;
|
|
||||||
}
|
|
||||||
result = dns_request_getresponse(revent->request, msg, 0);
|
result = dns_request_getresponse(revent->request, msg, 0);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
dns_zone_log(zone, ISC_LOG_INFO,
|
dns_zone_log(zone, ISC_LOG_INFO,
|
||||||
@ -13430,11 +13424,7 @@ create_query(dns_zone_t *zone, dns_rdatatype_t rdtype,
|
|||||||
dns_rdataset_t *qrdataset = NULL;
|
dns_rdataset_t *qrdataset = NULL;
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
result = dns_message_create(zone->mctx, DNS_MESSAGE_INTENTRENDER,
|
dns_message_create(zone->mctx, DNS_MESSAGE_INTENTRENDER, &message);
|
||||||
&message);
|
|
||||||
if (result != ISC_R_SUCCESS) {
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
message->opcode = dns_opcode_query;
|
message->opcode = dns_opcode_query;
|
||||||
message->rdclass = zone->rdclass;
|
message->rdclass = zone->rdclass;
|
||||||
@ -14313,11 +14303,7 @@ notify_createmessage(dns_zone_t *zone, unsigned int flags,
|
|||||||
REQUIRE(DNS_ZONE_VALID(zone));
|
REQUIRE(DNS_ZONE_VALID(zone));
|
||||||
REQUIRE(messagep != NULL && *messagep == NULL);
|
REQUIRE(messagep != NULL && *messagep == NULL);
|
||||||
|
|
||||||
result = dns_message_create(zone->mctx, DNS_MESSAGE_INTENTRENDER,
|
dns_message_create(zone->mctx, DNS_MESSAGE_INTENTRENDER, &message);
|
||||||
&message);
|
|
||||||
if (result != ISC_R_SUCCESS) {
|
|
||||||
return (result);
|
|
||||||
}
|
|
||||||
|
|
||||||
message->opcode = dns_opcode_notify;
|
message->opcode = dns_opcode_notify;
|
||||||
message->flags |= DNS_MESSAGEFLAG_AA;
|
message->flags |= DNS_MESSAGEFLAG_AA;
|
||||||
@ -15245,12 +15231,10 @@ notify_done(isc_task_t *task, isc_event_t *event) {
|
|||||||
|
|
||||||
isc_buffer_init(&buf, rcode, sizeof(rcode));
|
isc_buffer_init(&buf, rcode, sizeof(rcode));
|
||||||
isc_sockaddr_format(¬ify->dst, addrbuf, sizeof(addrbuf));
|
isc_sockaddr_format(¬ify->dst, addrbuf, sizeof(addrbuf));
|
||||||
|
dns_message_create(notify->zone->mctx, DNS_MESSAGE_INTENTPARSE,
|
||||||
|
&message);
|
||||||
|
|
||||||
result = revent->result;
|
result = revent->result;
|
||||||
if (result == ISC_R_SUCCESS) {
|
|
||||||
result = dns_message_create(notify->zone->mctx,
|
|
||||||
DNS_MESSAGE_INTENTPARSE, &message);
|
|
||||||
}
|
|
||||||
if (result == ISC_R_SUCCESS) {
|
if (result == ISC_R_SUCCESS) {
|
||||||
result =
|
result =
|
||||||
dns_request_getresponse(revent->request, message,
|
dns_request_getresponse(revent->request, message,
|
||||||
@ -15274,7 +15258,7 @@ notify_done(isc_task_t *task, isc_event_t *event) {
|
|||||||
* the soa if we see a formerr and had sent a SOA.
|
* the soa if we see a formerr and had sent a SOA.
|
||||||
*/
|
*/
|
||||||
isc_event_free(&event);
|
isc_event_free(&event);
|
||||||
if (message != NULL && message->rcode == dns_rcode_formerr &&
|
if (message->rcode == dns_rcode_formerr &&
|
||||||
(notify->flags & DNS_NOTIFY_NOSOA) == 0)
|
(notify->flags & DNS_NOTIFY_NOSOA) == 0)
|
||||||
{
|
{
|
||||||
bool startup;
|
bool startup;
|
||||||
@ -15293,9 +15277,7 @@ notify_done(isc_task_t *task, isc_event_t *event) {
|
|||||||
}
|
}
|
||||||
notify_destroy(notify, false);
|
notify_destroy(notify, false);
|
||||||
}
|
}
|
||||||
if (message != NULL) {
|
dns_message_detach(&message);
|
||||||
dns_message_detach(&message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct secure_event {
|
struct secure_event {
|
||||||
@ -17259,10 +17241,7 @@ forward_callback(isc_task_t *task, isc_event_t *event) {
|
|||||||
goto next_master;
|
goto next_master;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = dns_message_create(zone->mctx, DNS_MESSAGE_INTENTPARSE, &msg);
|
dns_message_create(zone->mctx, DNS_MESSAGE_INTENTPARSE, &msg);
|
||||||
if (result != ISC_R_SUCCESS) {
|
|
||||||
goto next_master;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = dns_request_getresponse(revent->request, msg,
|
result = dns_request_getresponse(revent->request, msg,
|
||||||
DNS_MESSAGEPARSE_PRESERVEORDER |
|
DNS_MESSAGEPARSE_PRESERVEORDER |
|
||||||
|
@ -2277,12 +2277,8 @@ ns__client_setup(ns_client_t *client, ns_clientmgr_t *mgr, bool new) {
|
|||||||
ns_server_attach(mgr->sctx, &client->sctx);
|
ns_server_attach(mgr->sctx, &client->sctx);
|
||||||
get_clienttask(mgr, &client->task);
|
get_clienttask(mgr, &client->task);
|
||||||
|
|
||||||
result = dns_message_create(client->mctx,
|
dns_message_create(client->mctx, DNS_MESSAGE_INTENTPARSE,
|
||||||
DNS_MESSAGE_INTENTPARSE,
|
&client->message);
|
||||||
&client->message);
|
|
||||||
if (result != ISC_R_SUCCESS) {
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
client->sendbuf = isc_mem_get(client->mctx,
|
client->sendbuf = isc_mem_get(client->mctx,
|
||||||
NS_CLIENT_SEND_BUFFER_SIZE);
|
NS_CLIENT_SEND_BUFFER_SIZE);
|
||||||
|
@ -66,8 +66,7 @@ check_response(isc_buffer_t *buf) {
|
|||||||
char rcodebuf[20];
|
char rcodebuf[20];
|
||||||
isc_buffer_t b;
|
isc_buffer_t b;
|
||||||
|
|
||||||
result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &message);
|
dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &message);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
result = dns_message_parse(message, buf, 0);
|
result = dns_message_parse(message, buf, 0);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
@ -115,8 +114,7 @@ notify_start(void **state) {
|
|||||||
isc_buffer_init(&nbuf, ndata, nsize);
|
isc_buffer_init(&nbuf, ndata, nsize);
|
||||||
isc_buffer_add(&nbuf, nsize);
|
isc_buffer_add(&nbuf, nsize);
|
||||||
|
|
||||||
result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &nmsg);
|
dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &nmsg);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
result = dns_message_parse(nmsg, &nbuf, 0);
|
result = dns_message_parse(nmsg, &nbuf, 0);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
@ -614,10 +614,7 @@ attach_query_msg_to_client(ns_client_t *client, const char *qnamestr,
|
|||||||
/*
|
/*
|
||||||
* Create a new DNS message holding a query.
|
* Create a new DNS message holding a query.
|
||||||
*/
|
*/
|
||||||
result = dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &message);
|
dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &message);
|
||||||
if (result != ISC_R_SUCCESS) {
|
|
||||||
return (result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set query ID to a random value.
|
* Set query ID to a random value.
|
||||||
|
@ -1334,8 +1334,8 @@ sendstream(xfrout_ctx_t *xfr) {
|
|||||||
* message.
|
* message.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CHECK(dns_message_create(xfr->mctx, DNS_MESSAGE_INTENTRENDER,
|
dns_message_create(xfr->mctx, DNS_MESSAGE_INTENTRENDER,
|
||||||
&tcpmsg));
|
&tcpmsg);
|
||||||
msg = tcpmsg;
|
msg = tcpmsg;
|
||||||
|
|
||||||
msg->id = xfr->id;
|
msg->id = xfr->id;
|
||||||
|
@ -1170,17 +1170,10 @@ main(int argc, char *argv[]) {
|
|||||||
probes[i].reqid = NULL;
|
probes[i].reqid = NULL;
|
||||||
|
|
||||||
probes[i].qmessage = NULL;
|
probes[i].qmessage = NULL;
|
||||||
result = dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER,
|
dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER,
|
||||||
&probes[i].qmessage);
|
&probes[i].qmessage);
|
||||||
if (result == ISC_R_SUCCESS) {
|
dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE,
|
||||||
result = dns_message_create(mctx,
|
&probes[i].rmessage);
|
||||||
DNS_MESSAGE_INTENTPARSE,
|
|
||||||
&probes[i].rmessage);
|
|
||||||
}
|
|
||||||
if (result != ISC_R_SUCCESS) {
|
|
||||||
fprintf(stderr, "initialization failure\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (i = 0; i < MAX_PROBES; i++) {
|
for (i = 0; i < MAX_PROBES; i++) {
|
||||||
result = probe_domain(&probes[i]);
|
result = probe_domain(&probes[i]);
|
||||||
|
@ -191,15 +191,8 @@ main(int argc, char *argv[]) {
|
|||||||
rmessage = NULL;
|
rmessage = NULL;
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create(&mctx);
|
||||||
result = dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &qmessage);
|
dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &qmessage);
|
||||||
if (result == ISC_R_SUCCESS) {
|
dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &rmessage);
|
||||||
result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE,
|
|
||||||
&rmessage);
|
|
||||||
}
|
|
||||||
if (result != ISC_R_SUCCESS) {
|
|
||||||
fprintf(stderr, "failed to create messages\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initialize the nameserver address */
|
/* Initialize the nameserver address */
|
||||||
memset(&hints, 0, sizeof(hints));
|
memset(&hints, 0, sizeof(hints));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user