2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

Fix various bugs reported by valgrind --tool=memcheck (#46978)

This commit is contained in:
Mukund Sivaraman
2018-01-13 00:31:30 +05:30
parent 1883d11ca2
commit f96133826e
13 changed files with 70 additions and 34 deletions

View File

@@ -2626,6 +2626,8 @@ ns__client_request(isc_task_t *task, isc_event_t *event) {
}
}
isc_sockaddr_fromnetaddr(&client->destsockaddr, &client->destaddr, 0);
if ((client->attributes & NS_CLIENTATTR_HAVEECS) != 0) {
ecs = &client->ecs;
}
@@ -3715,6 +3717,11 @@ ns_client_getsockaddr(ns_client_t *client) {
return (&client->peeraddr);
}
isc_sockaddr_t *
ns_client_getdestaddr(ns_client_t *client) {
return (&client->destsockaddr);
}
isc_result_t
ns_client_checkaclsilent(ns_client_t *client, isc_netaddr_t *netaddr,
dns_acl_t *acl, isc_boolean_t default_allow)

View File

@@ -135,6 +135,7 @@ struct ns_client {
isc_sockaddr_t peeraddr;
isc_boolean_t peeraddr_valid;
isc_netaddr_t destaddr;
isc_sockaddr_t destsockaddr;
dns_ecs_t ecs; /*%< EDNS client subnet sent by client */
@@ -303,6 +304,13 @@ ns_client_getsockaddr(ns_client_t *client);
* currently being processed.
*/
isc_sockaddr_t *
ns_client_getdestaddr(ns_client_t *client);
/*%<
* Get the destination address (server) for the request that is
* currently being processed.
*/
isc_result_t
ns_client_checkaclsilent(ns_client_t *client, isc_netaddr_t *netaddr,
dns_acl_t *acl, isc_boolean_t default_allow);

View File

@@ -80,7 +80,8 @@ ns_notify_start(ns_client_t *client) {
if (result != ISC_R_SUCCESS) {
notify_log(client, ISC_LOG_NOTICE,
"notify question section empty");
goto formerr;
result = DNS_R_FORMERR;
goto done;
}
/*
@@ -92,7 +93,8 @@ ns_notify_start(ns_client_t *client) {
if (ISC_LIST_NEXT(zone_rdataset, link) != NULL) {
notify_log(client, ISC_LOG_NOTICE,
"notify question section contains multiple RRs");
goto formerr;
result = DNS_R_FORMERR;
goto done;
}
/* The zone section must have exactly one name. */
@@ -100,14 +102,16 @@ ns_notify_start(ns_client_t *client) {
if (result != ISC_R_NOMORE) {
notify_log(client, ISC_LOG_NOTICE,
"notify question section contains multiple RRs");
goto formerr;
result = DNS_R_FORMERR;
goto done;
}
/* The one rdataset must be an SOA. */
if (zone_rdataset->type != dns_rdatatype_soa) {
notify_log(client, ISC_LOG_NOTICE,
"notify question section contains no SOA");
goto formerr;
result = DNS_R_FORMERR;
goto done;
}
tsigkey = dns_message_gettsigkey(request);
@@ -126,38 +130,33 @@ ns_notify_start(ns_client_t *client) {
}
} else
tsigbuf[0] = '\0';
dns_name_format(zonename, namebuf, sizeof(namebuf));
result = dns_zt_find(client->view->zonetable, zonename, 0, NULL,
&zone);
if (result != ISC_R_SUCCESS)
goto notauth;
result = dns_zt_find(client->view->zonetable, zonename, 0, NULL, &zone);
if (result == ISC_R_SUCCESS) {
dns_zonetype_t zonetype = dns_zone_gettype(zone);
switch (dns_zone_gettype(zone)) {
case dns_zone_master:
case dns_zone_slave:
case dns_zone_stub: /* Allow dialup passive to work. */
notify_log(client, ISC_LOG_INFO,
"received notify for zone '%s'%s", namebuf, tsigbuf);
respond(client, dns_zone_notifyreceive(zone,
ns_client_getsockaddr(client), request));
break;
default:
goto notauth;
if ((zonetype == dns_zone_master) ||
(zonetype == dns_zone_slave) ||
(zonetype == dns_zone_stub))
{
isc_sockaddr_t *from = ns_client_getsockaddr(client);
isc_sockaddr_t *to = ns_client_getdestaddr(client);
notify_log(client, ISC_LOG_INFO,
"received notify for zone '%s'%s",
namebuf, tsigbuf);
result = dns_zone_notifyreceive2(zone, from, to,
request);
goto done;
}
}
dns_zone_detach(&zone);
return;
notauth:
notify_log(client, ISC_LOG_NOTICE,
"received notify for zone '%s'%s: not authoritative",
namebuf, tsigbuf);
result = DNS_R_NOTAUTH;
goto failure;
formerr:
result = DNS_R_FORMERR;
failure:
done:
if (zone != NULL)
dns_zone_detach(&zone);
respond(client, result);

View File

@@ -18,6 +18,7 @@ ns_client_detach
ns_client_dumprecursing
ns_client_error
ns_client_getsockaddr
ns_client_getdestaddr
ns_client_killoldestquery
ns_client_log
ns_client_logv