Commit d27a061f authored by Evan Hunt's avatar Evan Hunt

Merge branch...

Merge branch '937-potential-null-pointer-dereference-in-bin-tests-system-dlzexternal-driver-c' into 'master'

Resolve "potential null pointer dereference in bin/tests/system/dlzexternal/driver.c"

Closes #937

See merge request !1683
parents f881c7b4 7bf67503
Pipeline #11977 passed with stages
in 57 seconds
......@@ -38,6 +38,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];
......@@ -107,9 +114,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);
}
......@@ -242,9 +247,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);
}
......@@ -280,9 +283,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);
......@@ -300,10 +301,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);
}
......@@ -331,10 +329,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
......@@ -434,7 +430,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
......@@ -454,10 +450,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) {
......@@ -472,8 +467,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);
......@@ -537,19 +531,12 @@ dlz_allowzonexfr(void *dbdata, const char *name, const char *client) {
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: dlz_allowzonexfr called for %s",
name);
}
loginfo("dlz_example: dlz_allowzonexfr called for %s", name);
result = dlz_findzonedb(dbdata, name, NULL, NULL);
if (result != ISC_R_SUCCESS) {
if (state->log != NULL) {
state->log(ISC_LOG_INFO,
"dlz_example: findzonedb returned %s",
isc_result_totext(result));
}
loginfo("dlz_example: findzonedb returned %s",
isc_result_totext(result));
return (result);
}
......@@ -558,11 +545,7 @@ dlz_allowzonexfr(void *dbdata, const char *name, const char *client) {
* the view ACL.
*/
if (strcmp(name, "example.org") == 0) {
if (state->log != NULL) {
state->log(ISC_LOG_INFO,
"dlz_example: use view ACL "
"for example.org");
}
loginfo("dlz_example: use view ACL for example.org");
return (ISC_R_DEFAULT);
}
......@@ -571,18 +554,11 @@ dlz_allowzonexfr(void *dbdata, const char *name, const char *client) {
* is effective.
*/
if (strcmp(client, "10.53.0.5") == 0) {
if (state->log != NULL) {
state->log(ISC_LOG_INFO,
"dlz_example: disallow transfer "
"to 10.53.0.5");
}
loginfo("dlz_example: disallow transfer to 10.53.0.5");
return (ISC_R_NOPERM);
}
if (state->log != NULL) {
state->log(ISC_LOG_INFO,
"dlz_example: transfer allowed for %s", name);
}
loginfo("dlz_example: transfer allowed for %s", name);
return (ISC_R_SUCCESS);
}
......@@ -625,10 +601,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);
}
......@@ -648,9 +622,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;
}
......@@ -661,9 +634,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],
......@@ -683,9 +654,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));
......@@ -700,27 +669,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);
}
......@@ -741,14 +704,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);
}
......@@ -819,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]));
}
......@@ -835,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]));
}
......@@ -851,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);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment