4618. [bug] Check isc_mem_strdup results in dns_view_setnewzones.

Add logging for lmdb call failures. [RT #45204]

(cherry picked from commit d242bf393c)
This commit is contained in:
Mark Andrews
2017-05-10 10:51:48 +10:00
parent 638068f7e7
commit 9604a49da0
2 changed files with 25 additions and 0 deletions
+3
View File
@@ -1,3 +1,6 @@
4618. [bug] Check isc_mem_strdup results in dns_view_setnewzones.
Add logging for lmdb call failures. [RT #45204]
4617. [test] Update rndc system test to be more delay tolerant.
[RT #45177]
+22
View File
@@ -2031,17 +2031,31 @@ dns_view_setnewzones(dns_view_t *view, isc_boolean_t allow, void *cfgctx,
buffer, sizeof(buffer));
if (result != ISC_R_SUCCESS)
goto out;
view->new_zone_file = isc_mem_strdup(view->mctx, buffer);
if (view->new_zone_file == NULL) {
result = ISC_R_NOMEMORY;
goto out;
}
#ifdef HAVE_LMDB
result = isc_file_sanitize(NULL, view->name, "nzd",
buffer, sizeof(buffer));
if (result != ISC_R_SUCCESS)
goto out;
view->new_zone_db = isc_mem_strdup(view->mctx, buffer);
if (view->new_zone_db == NULL) {
result = ISC_R_NOMEMORY;
goto out;
}
status = mdb_env_create(&env);
if (status != 0) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL,
ISC_LOGMODULE_OTHER, ISC_LOG_ERROR,
"mdb_env_create failed: %s",
mdb_strerror(status));
result = ISC_R_FAILURE;
goto out;
}
@@ -2049,6 +2063,10 @@ dns_view_setnewzones(dns_view_t *view, isc_boolean_t allow, void *cfgctx,
if (mapsize != 0ULL) {
status = mdb_env_set_mapsize(env, mapsize);
if (status != 0) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL,
ISC_LOGMODULE_OTHER, ISC_LOG_ERROR,
"mdb_env_set_mapsize failed: %s",
mdb_strerror(status));
result = ISC_R_FAILURE;
goto out;
}
@@ -2057,6 +2075,10 @@ dns_view_setnewzones(dns_view_t *view, isc_boolean_t allow, void *cfgctx,
status = mdb_env_open(env, view->new_zone_db,
MDB_NOSUBDIR|MDB_CREATE, 0600);
if (status != 0) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL,
ISC_LOGMODULE_OTHER, ISC_LOG_ERROR,
"mdb_env_open of '%s' failed: %s",
view->new_zone_db, mdb_strerror(status));
result = ISC_R_FAILURE;
goto out;
}