2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +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:
Ondřej Surý
2020-09-25 11:51:36 +02:00
parent 7deaf9a93c
commit 33eefe9f85
23 changed files with 147 additions and 172 deletions

View File

@@ -12639,10 +12639,7 @@ stub_callback(isc_task_t *task, isc_event_t *event) {
goto next_master;
}
result = dns_message_create(zone->mctx, DNS_MESSAGE_INTENTPARSE, &msg);
if (result != ISC_R_SUCCESS) {
goto next_master;
}
dns_message_create(zone->mctx, DNS_MESSAGE_INTENTPARSE, &msg);
result = dns_request_getresponse(revent->request, msg, 0);
if (result != ISC_R_SUCCESS) {
@@ -13044,10 +13041,7 @@ refresh_callback(isc_task_t *task, isc_event_t *event) {
goto next_master;
}
result = dns_message_create(zone->mctx, DNS_MESSAGE_INTENTPARSE, &msg);
if (result != ISC_R_SUCCESS) {
goto next_master;
}
dns_message_create(zone->mctx, DNS_MESSAGE_INTENTPARSE, &msg);
result = dns_request_getresponse(revent->request, msg, 0);
if (result != ISC_R_SUCCESS) {
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;
isc_result_t result;
result = dns_message_create(zone->mctx, DNS_MESSAGE_INTENTRENDER,
&message);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
dns_message_create(zone->mctx, DNS_MESSAGE_INTENTRENDER, &message);
message->opcode = dns_opcode_query;
message->rdclass = zone->rdclass;
@@ -14313,11 +14303,7 @@ notify_createmessage(dns_zone_t *zone, unsigned int flags,
REQUIRE(DNS_ZONE_VALID(zone));
REQUIRE(messagep != NULL && *messagep == NULL);
result = dns_message_create(zone->mctx, DNS_MESSAGE_INTENTRENDER,
&message);
if (result != ISC_R_SUCCESS) {
return (result);
}
dns_message_create(zone->mctx, DNS_MESSAGE_INTENTRENDER, &message);
message->opcode = dns_opcode_notify;
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_sockaddr_format(&notify->dst, addrbuf, sizeof(addrbuf));
dns_message_create(notify->zone->mctx, DNS_MESSAGE_INTENTPARSE,
&message);
result = revent->result;
if (result == ISC_R_SUCCESS) {
result = dns_message_create(notify->zone->mctx,
DNS_MESSAGE_INTENTPARSE, &message);
}
if (result == ISC_R_SUCCESS) {
result =
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.
*/
isc_event_free(&event);
if (message != NULL && message->rcode == dns_rcode_formerr &&
if (message->rcode == dns_rcode_formerr &&
(notify->flags & DNS_NOTIFY_NOSOA) == 0)
{
bool startup;
@@ -15293,9 +15277,7 @@ notify_done(isc_task_t *task, isc_event_t *event) {
}
notify_destroy(notify, false);
}
if (message != NULL) {
dns_message_detach(&message);
}
dns_message_detach(&message);
}
struct secure_event {
@@ -17259,10 +17241,7 @@ forward_callback(isc_task_t *task, isc_event_t *event) {
goto next_master;
}
result = dns_message_create(zone->mctx, DNS_MESSAGE_INTENTPARSE, &msg);
if (result != ISC_R_SUCCESS) {
goto next_master;
}
dns_message_create(zone->mctx, DNS_MESSAGE_INTENTPARSE, &msg);
result = dns_request_getresponse(revent->request, msg,
DNS_MESSAGEPARSE_PRESERVEORDER |