mirror of
https://github.com/isc-projects/bind9.git
synced 2026-04-26 16:47:31 -04:00
Merge branch '937-potential-null-pointer-dereference-in-bin-tests-system-dlzexternal-driver-c-v9_11' into 'v9_11'
Resolve "potential null pointer dereference in bin/tests/system/dlzexternal/driver.c" See merge request isc-projects/bind9!1691
This commit is contained in:
commit
be1dc0d82c
1 changed files with 43 additions and 63 deletions
|
|
@ -48,6 +48,13 @@
|
|||
goto failure; \
|
||||
} while (0)
|
||||
|
||||
#define loginfo(...) \
|
||||
({ if ((state != NULL) && (state->log != NULL)) \
|
||||
state->log(ISC_LOG_INFO, __VA_ARGS__); })
|
||||
#define logerr(...) \
|
||||
({ if ((state != NULL) && (state->log != NULL)) \
|
||||
state->log(ISC_LOG_ERROR, __VA_ARGS__); })
|
||||
|
||||
/* For this simple example, use fixed sized strings */
|
||||
struct record {
|
||||
char name[100];
|
||||
|
|
@ -117,9 +124,7 @@ add_name(struct dlz_example_data *state, struct record *list,
|
|||
i = first_empty;
|
||||
}
|
||||
if (i == MAX_RECORDS) {
|
||||
if (state->log != NULL)
|
||||
state->log(ISC_LOG_ERROR,
|
||||
"dlz_example: out of record space");
|
||||
logerr("dlz_example: out of record space");
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -249,9 +254,7 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[],
|
|||
va_end(ap);
|
||||
|
||||
if (argc < 2 || argv[1][0] == '\0') {
|
||||
if (state->log != NULL)
|
||||
state->log(ISC_LOG_ERROR,
|
||||
"dlz_example: please specify a zone name");
|
||||
logerr("dlz_example: please specify a zone name");
|
||||
dlz_destroy(state);
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
|
|
@ -287,9 +290,7 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[],
|
|||
add_name(state, &state->current[0], state->zone_name,
|
||||
"a", 1800, "10.53.0.1");
|
||||
|
||||
if (state->log != NULL)
|
||||
state->log(ISC_LOG_INFO, "dlz_example: started for zone %s",
|
||||
state->zone_name);
|
||||
loginfo("dlz_example: started for zone %s", state->zone_name);
|
||||
|
||||
*dbdata = state;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
|
@ -307,10 +308,7 @@ void
|
|||
dlz_destroy(void *dbdata) {
|
||||
struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
|
||||
|
||||
if (state->log != NULL)
|
||||
state->log(ISC_LOG_INFO,
|
||||
"dlz_example: shutting down zone %s",
|
||||
state->zone_name);
|
||||
loginfo("dlz_example: shutting down zone %s", state->zone_name);
|
||||
free(state->zone_name);
|
||||
free(state);
|
||||
}
|
||||
|
|
@ -338,10 +336,8 @@ dlz_findzonedb(void *dbdata, const char *name,
|
|||
fmt_address(src, addrbuf, sizeof(addrbuf));
|
||||
}
|
||||
|
||||
state->log(ISC_LOG_INFO,
|
||||
"dlz_example: dlz_findzonedb called with name '%s' "
|
||||
"in zone DB '%s' from %s",
|
||||
name, state->zone_name, addrbuf);
|
||||
loginfo("dlz_example: dlz_findzonedb called with name '%s' "
|
||||
"in zone DB '%s' from %s", name, state->zone_name, addrbuf);
|
||||
|
||||
/*
|
||||
* Returning ISC_R_NOTFOUND will cause the query logic to
|
||||
|
|
@ -441,7 +437,7 @@ dlz_lookup(const char *zone, const char *name, void *dbdata,
|
|||
count = 1;
|
||||
memcpy(last, full_name, size + 1);
|
||||
}
|
||||
state->log(ISC_LOG_INFO, "lookup #%d for %s", count, full_name);
|
||||
loginfo("lookup #%d for %s", count, full_name);
|
||||
|
||||
/*
|
||||
* If we need to know the database version (as set in
|
||||
|
|
@ -461,10 +457,9 @@ dlz_lookup(const char *zone, const char *name, void *dbdata,
|
|||
if (clientinfo != NULL &&
|
||||
clientinfo->version >= DNS_CLIENTINFO_VERSION) {
|
||||
dbversion = clientinfo->dbversion;
|
||||
if (dbversion != NULL && *(bool *)dbversion)
|
||||
state->log(ISC_LOG_INFO,
|
||||
"dlz_example: lookup against live "
|
||||
"transaction");
|
||||
if (dbversion != NULL && *(bool *)dbversion) {
|
||||
loginfo("dlz_example: lookup against live transaction");
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp(name, "source-addr") == 0) {
|
||||
|
|
@ -479,8 +474,7 @@ dlz_lookup(const char *zone, const char *name, void *dbdata,
|
|||
fmt_address(src, buf, sizeof(buf));
|
||||
}
|
||||
|
||||
state->log(ISC_LOG_INFO,
|
||||
"dlz_example: lookup connection from %s", buf);
|
||||
loginfo("dlz_example: lookup connection from %s", buf);
|
||||
|
||||
found = true;
|
||||
result = state->putrr(lookup, "TXT", 0, buf);
|
||||
|
|
@ -541,10 +535,15 @@ dlz_lookup(const char *zone, const char *name, void *dbdata,
|
|||
*/
|
||||
isc_result_t
|
||||
dlz_allowzonexfr(void *dbdata, const char *name, const char *client) {
|
||||
struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
|
||||
isc_result_t result;
|
||||
|
||||
loginfo("dlz_example: dlz_allowzonexfr called for %s", name);
|
||||
|
||||
result = dlz_findzonedb(dbdata, name, NULL, NULL);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
loginfo("dlz_example: findzonedb returned %s",
|
||||
isc_result_totext(result));
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
|
@ -553,9 +552,12 @@ dlz_allowzonexfr(void *dbdata, const char *name, const char *client) {
|
|||
* is effective.
|
||||
*/
|
||||
if (strcmp(client, "10.53.0.5") == 0) {
|
||||
loginfo("dlz_example: disallow transfer to 10.53.0.5");
|
||||
return (ISC_R_NOPERM);
|
||||
}
|
||||
|
||||
loginfo("dlz_example: transfer allowed for %s", name);
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
|
|
@ -597,10 +599,8 @@ dlz_newversion(const char *zone, void *dbdata, void **versionp) {
|
|||
struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
|
||||
|
||||
if (state->transaction_started) {
|
||||
if (state->log != NULL)
|
||||
state->log(ISC_LOG_INFO,
|
||||
"dlz_example: transaction already "
|
||||
"started for zone %s", zone);
|
||||
loginfo("dlz_example: transaction already started for zone %s",
|
||||
zone);
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -620,9 +620,8 @@ dlz_closeversion(const char *zone, bool commit,
|
|||
struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
|
||||
|
||||
if (!state->transaction_started) {
|
||||
if (state->log != NULL)
|
||||
state->log(ISC_LOG_INFO, "dlz_example: transaction not "
|
||||
"started for zone %s", zone);
|
||||
loginfo("dlz_example: transaction not started for zone %s",
|
||||
zone);
|
||||
*versionp = NULL;
|
||||
return;
|
||||
}
|
||||
|
|
@ -633,9 +632,7 @@ dlz_closeversion(const char *zone, bool commit,
|
|||
|
||||
if (commit) {
|
||||
int i;
|
||||
if (state->log != NULL)
|
||||
state->log(ISC_LOG_INFO, "dlz_example: committing "
|
||||
"transaction on zone %s", zone);
|
||||
loginfo("dlz_example: committing transaction on zone %s", zone);
|
||||
for (i = 0; i < MAX_RECORDS; i++) {
|
||||
if (strlen(state->deletes[i].name) > 0U) {
|
||||
(void)del_name(state, &state->current[0],
|
||||
|
|
@ -655,9 +652,7 @@ dlz_closeversion(const char *zone, bool commit,
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (state->log != NULL)
|
||||
state->log(ISC_LOG_INFO, "dlz_example: cancelling "
|
||||
"transaction on zone %s", zone);
|
||||
loginfo("dlz_example: cancelling transaction on zone %s", zone);
|
||||
}
|
||||
memset(state->adds, 0, sizeof(state->adds));
|
||||
memset(state->deletes, 0, sizeof(state->deletes));
|
||||
|
|
@ -672,27 +667,21 @@ dlz_configure(dns_view_t *view, dns_dlzdb_t *dlzdb, void *dbdata) {
|
|||
struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
|
||||
isc_result_t result;
|
||||
|
||||
if (state->log != NULL)
|
||||
state->log(ISC_LOG_INFO, "dlz_example: starting configure");
|
||||
loginfo("dlz_example: starting configure");
|
||||
|
||||
if (state->writeable_zone == NULL) {
|
||||
if (state->log != NULL)
|
||||
state->log(ISC_LOG_INFO, "dlz_example: no "
|
||||
"writeable_zone method available");
|
||||
loginfo("dlz_example: no writeable_zone method available");
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
|
||||
result = state->writeable_zone(view, dlzdb, state->zone_name);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
if (state->log != NULL)
|
||||
state->log(ISC_LOG_ERROR, "dlz_example: failed to "
|
||||
"configure zone %s", state->zone_name);
|
||||
loginfo("dlz_example: failed to configure zone %s",
|
||||
state->zone_name);
|
||||
return (result);
|
||||
}
|
||||
|
||||
if (state->log != NULL)
|
||||
state->log(ISC_LOG_INFO, "dlz_example: configured writeable "
|
||||
"zone %s", state->zone_name);
|
||||
loginfo("dlz_example: configured writeable zone %s", state->zone_name);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
|
|
@ -713,14 +702,11 @@ dlz_ssumatch(const char *signer, const char *name, const char *tcpaddr,
|
|||
UNUSED(keydata);
|
||||
|
||||
if (strncmp(name, "deny.", 5) == 0) {
|
||||
if (state->log != NULL)
|
||||
state->log(ISC_LOG_INFO, "dlz_example: denying update "
|
||||
"of name=%s by %s", name, signer);
|
||||
loginfo("dlz_example: denying update of name=%s by %s",
|
||||
name, signer);
|
||||
return (false);
|
||||
}
|
||||
if (state->log != NULL)
|
||||
state->log(ISC_LOG_INFO, "dlz_example: allowing update of "
|
||||
"name=%s by %s", name, signer);
|
||||
loginfo("dlz_example: allowing update of name=%s by %s", name, signer);
|
||||
return (true);
|
||||
}
|
||||
|
||||
|
|
@ -793,9 +779,7 @@ dlz_addrdataset(const char *name, const char *rdatastr,
|
|||
if (version != (void *) &state->transaction_started)
|
||||
return (ISC_R_FAILURE);
|
||||
|
||||
if (state->log != NULL)
|
||||
state->log(ISC_LOG_INFO, "dlz_example: adding rdataset %s '%s'",
|
||||
name, rdatastr);
|
||||
loginfo("dlz_example: adding rdataset %s '%s'", name, rdatastr);
|
||||
|
||||
return (modrdataset(state, name, rdatastr, &state->adds[0]));
|
||||
}
|
||||
|
|
@ -809,9 +793,7 @@ dlz_subrdataset(const char *name, const char *rdatastr,
|
|||
if (version != (void *) &state->transaction_started)
|
||||
return (ISC_R_FAILURE);
|
||||
|
||||
if (state->log != NULL)
|
||||
state->log(ISC_LOG_INFO, "dlz_example: subtracting rdataset "
|
||||
"%s '%s'", name, rdatastr);
|
||||
loginfo("dlz_example: subtracting rdataset %s '%s'", name, rdatastr);
|
||||
|
||||
return (modrdataset(state, name, rdatastr, &state->deletes[0]));
|
||||
}
|
||||
|
|
@ -825,9 +807,7 @@ dlz_delrdataset(const char *name, const char *type,
|
|||
if (version != (void *) &state->transaction_started)
|
||||
return (ISC_R_FAILURE);
|
||||
|
||||
if (state->log != NULL)
|
||||
state->log(ISC_LOG_INFO, "dlz_example: deleting rdataset %s "
|
||||
"of type %s", name, type);
|
||||
loginfo("dlz_example: deleting rdataset %s of type %s", name, type);
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue