mirror of
https://github.com/isc-projects/bind9.git
synced 2026-02-22 17:30:44 -05:00
Use coccinelle to cleanup the failure handling blocks from isc_mem_strdup
This commit is contained in:
parent
601cb4e4cc
commit
9bdc24a9fd
37 changed files with 10 additions and 269 deletions
|
|
@ -140,8 +140,6 @@ add(char *key, int value) {
|
|||
}
|
||||
|
||||
key = isc_mem_strdup(sym_mctx, key);
|
||||
if (key == NULL)
|
||||
return;
|
||||
|
||||
symvalue.as_pointer = NULL;
|
||||
result = isc_symtab_define(symtab, key, value, symvalue,
|
||||
|
|
|
|||
|
|
@ -714,9 +714,6 @@ setup_dnsseckeys(dns_client_t *client) {
|
|||
|
||||
if (trust_anchor == NULL) {
|
||||
trust_anchor = isc_mem_strdup(mctx, ".");
|
||||
if (trust_anchor == NULL) {
|
||||
fatal("out of memory");
|
||||
}
|
||||
}
|
||||
|
||||
if (trust_anchor != NULL) {
|
||||
|
|
@ -1032,8 +1029,6 @@ plus_option(char *option) {
|
|||
dlv_validation = state;
|
||||
if (value != NULL) {
|
||||
dlv_anchor = isc_mem_strdup(mctx, value);
|
||||
if (dlv_anchor == NULL)
|
||||
fatal("out of memory");
|
||||
}
|
||||
break;
|
||||
case 'n': /* dnssec */
|
||||
|
|
@ -1068,8 +1063,6 @@ plus_option(char *option) {
|
|||
root_validation = state;
|
||||
if (value != NULL) {
|
||||
trust_anchor = isc_mem_strdup(mctx, value);
|
||||
if (trust_anchor == NULL)
|
||||
fatal("out of memory");
|
||||
}
|
||||
break;
|
||||
case 'r': /* rrcomments */
|
||||
|
|
@ -1252,8 +1245,6 @@ dash_option(char *option, char *next, bool *open_type_class) {
|
|||
switch (opt) {
|
||||
case 'a':
|
||||
anchorfile = isc_mem_strdup(mctx, value);
|
||||
if (anchorfile == NULL)
|
||||
fatal("out of memory");
|
||||
return (value_from_next);
|
||||
case 'b':
|
||||
hash = strchr(value, '#');
|
||||
|
|
@ -1317,8 +1308,6 @@ dash_option(char *option, char *next, bool *open_type_class) {
|
|||
isc_mem_free(mctx, curqname);
|
||||
}
|
||||
curqname = isc_mem_strdup(mctx, value);
|
||||
if (curqname == NULL)
|
||||
fatal("out of memory");
|
||||
return (value_from_next);
|
||||
case 't':
|
||||
*open_type_class = false;
|
||||
|
|
@ -1346,8 +1335,6 @@ dash_option(char *option, char *next, bool *open_type_class) {
|
|||
warn("extra query name");
|
||||
}
|
||||
curqname = isc_mem_strdup(mctx, textname);
|
||||
if (curqname == NULL)
|
||||
fatal("out of memory");
|
||||
if (typeset)
|
||||
warn("extra query type");
|
||||
qtype = dns_rdatatype_ptr;
|
||||
|
|
@ -1494,8 +1481,6 @@ parse_args(int argc, char **argv) {
|
|||
|
||||
if (curqname == NULL) {
|
||||
curqname = isc_mem_strdup(mctx, argv[0]);
|
||||
if (curqname == NULL)
|
||||
fatal("out of memory");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1509,8 +1494,6 @@ parse_args(int argc, char **argv) {
|
|||
|
||||
if (curqname == NULL) {
|
||||
qname = isc_mem_strdup(mctx, ".");
|
||||
if (qname == NULL)
|
||||
fatal("out of memory");
|
||||
|
||||
if (!typeset)
|
||||
qtype = dns_rdatatype_ns;
|
||||
|
|
|
|||
|
|
@ -113,10 +113,6 @@ main(int argc, char **argv) {
|
|||
* simplify cleanup later
|
||||
*/
|
||||
dir = isc_mem_strdup(mctx, isc_commandline_argument);
|
||||
if (dir == NULL) {
|
||||
fatal("Failed to allocate memory for "
|
||||
"directory");
|
||||
}
|
||||
break;
|
||||
case 'r':
|
||||
removefile = true;
|
||||
|
|
|
|||
|
|
@ -253,10 +253,6 @@ main(int argc, char **argv) {
|
|||
*/
|
||||
directory = isc_mem_strdup(mctx,
|
||||
isc_commandline_argument);
|
||||
if (directory == NULL) {
|
||||
fatal("Failed to allocate memory for "
|
||||
"directory");
|
||||
}
|
||||
break;
|
||||
case 'L':
|
||||
ttl = strtottl(isc_commandline_argument);
|
||||
|
|
|
|||
|
|
@ -723,8 +723,6 @@ controlkeylist_fromcfg(const cfg_obj_t *keylist, isc_mem_t *mctx,
|
|||
obj = cfg_listelt_value(element);
|
||||
str = cfg_obj_asstring(obj);
|
||||
newstr = isc_mem_strdup(mctx, str);
|
||||
if (newstr == NULL)
|
||||
goto cleanup;
|
||||
key = isc_mem_get(mctx, sizeof(*key));
|
||||
key->keyname = newstr;
|
||||
key->algorithm = DST_ALG_UNKNOWN;
|
||||
|
|
|
|||
|
|
@ -6969,8 +6969,6 @@ setstring(named_server_t *server, char **field, const char *value) {
|
|||
|
||||
if (value != NULL) {
|
||||
copy = isc_mem_strdup(server->mctx, value);
|
||||
if (copy == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
} else {
|
||||
copy = NULL;
|
||||
}
|
||||
|
|
@ -7313,8 +7311,6 @@ configure_session_key(const cfg_obj_t **maps, named_server_t *server,
|
|||
CHECK(dns_name_dup(keyname, mctx, server->session_keyname));
|
||||
|
||||
server->session_keyfile = isc_mem_strdup(mctx, keyfile);
|
||||
if (server->session_keyfile == NULL)
|
||||
goto cleanup;
|
||||
|
||||
server->session_keyalg = algtype;
|
||||
server->session_keybits = bits;
|
||||
|
|
@ -8005,7 +8001,7 @@ check_lockfile(named_server_t *server, const cfg_obj_t *config,
|
|||
"'lock-file' has no effect "
|
||||
"because the server was run with -X");
|
||||
server->lockfile = isc_mem_strdup(server->mctx,
|
||||
named_g_defaultlockfile);
|
||||
named_g_defaultlockfile);
|
||||
} else {
|
||||
filename = cfg_obj_asstring(obj);
|
||||
server->lockfile = isc_mem_strdup(server->mctx,
|
||||
|
|
|
|||
|
|
@ -105,10 +105,6 @@ named_tkeyctx_fromconfig(const cfg_obj_t *options, isc_mem_t *mctx,
|
|||
if (result == ISC_R_SUCCESS) {
|
||||
s = cfg_obj_asstring(obj);
|
||||
tctx->gssapi_keytab = isc_mem_strdup(mctx, s);
|
||||
if (tctx->gssapi_keytab == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto failure;
|
||||
}
|
||||
}
|
||||
|
||||
*tctxp = tctx;
|
||||
|
|
|
|||
|
|
@ -235,16 +235,8 @@ dlopen_dlz_create(const char *dlzname, unsigned int argc, char *argv[],
|
|||
cd->mctx = mctx;
|
||||
|
||||
cd->dl_path = isc_mem_strdup(cd->mctx, argv[1]);
|
||||
if (cd->dl_path == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto failed;
|
||||
}
|
||||
|
||||
cd->dlzname = isc_mem_strdup(cd->mctx, dlzname);
|
||||
if (cd->dlzname == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto failed;
|
||||
}
|
||||
|
||||
/* Initialize the lock */
|
||||
isc_mutex_init(&cd->lock);
|
||||
|
|
|
|||
|
|
@ -232,16 +232,8 @@ dlopen_dlz_create(const char *dlzname, unsigned int argc, char *argv[],
|
|||
cd->mctx = mctx;
|
||||
|
||||
cd->dl_path = isc_mem_strdup(cd->mctx, argv[1]);
|
||||
if (cd->dl_path == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto failed;
|
||||
}
|
||||
|
||||
cd->dlzname = isc_mem_strdup(cd->mctx, dlzname);
|
||||
if (cd->dlzname == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto failed;
|
||||
}
|
||||
|
||||
triedload = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -1671,8 +1671,6 @@ evaluate_realm(char *cmdline) {
|
|||
return (STATUS_SYNTAX);
|
||||
}
|
||||
realm = isc_mem_strdup(gmctx, buf);
|
||||
if (realm == NULL)
|
||||
fatal("out of memory");
|
||||
return (STATUS_MORE);
|
||||
#else
|
||||
UNUSED(cmdline);
|
||||
|
|
|
|||
|
|
@ -82,10 +82,6 @@ dyndb_init(isc_mem_t *mctx, const char *name, const char *parameters,
|
|||
}
|
||||
|
||||
s = isc_mem_strdup(mctx, parameters);
|
||||
if (s == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
result = isc_commandline_strtoargv(mctx, s, &argc, &argv, 0);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
|
|
|
|||
|
|
@ -95,10 +95,6 @@ new_sample_instance(isc_mem_t *mctx, const char *db_name,
|
|||
isc_mem_attach(mctx, &inst->mctx);
|
||||
|
||||
inst->db_name = isc_mem_strdup(mctx, db_name);
|
||||
if (inst->db_name == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
inst->zone1_name = dns_fixedname_initname(&inst->zone1_fn);
|
||||
inst->zone2_name = dns_fixedname_initname(&inst->zone2_fn);
|
||||
|
|
|
|||
|
|
@ -164,8 +164,6 @@ create_path_helper(char *out, const char *in, config_data_t *cd) {
|
|||
int i;
|
||||
|
||||
tmpString = isc_mem_strdup(named_g_mctx, in);
|
||||
if (tmpString == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
|
||||
/*
|
||||
* don't forget is_safe guarantees '.' will NOT be the
|
||||
|
|
@ -897,20 +895,14 @@ fs_create(const char *dlzname, unsigned int argc, char *argv[],
|
|||
|
||||
/* get and store our base directory */
|
||||
cd->basedir = isc_mem_strdup(named_g_mctx, argv[1]);
|
||||
if (cd->basedir == NULL)
|
||||
goto no_mem;
|
||||
cd->basedirsize = strlen(cd->basedir);
|
||||
|
||||
/* get and store our data sub-dir */
|
||||
cd->datadir = isc_mem_strdup(named_g_mctx, argv[2]);
|
||||
if (cd->datadir == NULL)
|
||||
goto no_mem;
|
||||
cd->datadirsize = strlen(cd->datadir);
|
||||
|
||||
/* get and store our zone xfr sub-dir */
|
||||
cd->xfrdir = isc_mem_strdup(named_g_mctx, argv[3]);
|
||||
if (cd->xfrdir == NULL)
|
||||
goto no_mem;
|
||||
cd->xfrdirsize = strlen(cd->xfrdir);
|
||||
|
||||
/* get and store our directory split count */
|
||||
|
|
|
|||
|
|
@ -562,28 +562,16 @@ ldap_get_results(const char *zone, const char *record,
|
|||
/* set fields */
|
||||
if (zone != NULL) {
|
||||
dbi->zone = isc_mem_strdup(named_g_mctx, zone);
|
||||
if (dbi->zone == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto cleanup;
|
||||
}
|
||||
} else {
|
||||
dbi->zone = NULL;
|
||||
}
|
||||
if (record != NULL) {
|
||||
dbi->record = isc_mem_strdup(named_g_mctx, record);
|
||||
if (dbi->record == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto cleanup;
|
||||
}
|
||||
} else {
|
||||
dbi->record = NULL;
|
||||
}
|
||||
if (client != NULL) {
|
||||
dbi->client = isc_mem_strdup(named_g_mctx, client);
|
||||
if (dbi->client == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto cleanup;
|
||||
}
|
||||
} else {
|
||||
dbi->client = NULL;
|
||||
}
|
||||
|
|
@ -1012,20 +1000,8 @@ dlz_ldap_create(const char *dlzname, unsigned int argc, char *argv[],
|
|||
ldap_inst->protocol = protocol;
|
||||
ldap_inst->method = method;
|
||||
ldap_inst->hosts = isc_mem_strdup(named_g_mctx, argv[6]);
|
||||
if (ldap_inst->hosts == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto cleanup;
|
||||
}
|
||||
ldap_inst->user = isc_mem_strdup(named_g_mctx, argv[4]);
|
||||
if (ldap_inst->user == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto cleanup;
|
||||
}
|
||||
ldap_inst->cred = isc_mem_strdup(named_g_mctx, argv[5]);
|
||||
if (ldap_inst->cred == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* allocate memory for database connection list */
|
||||
ldap_inst->db = isc_mem_get(named_g_mctx, sizeof(db_list_t));
|
||||
|
|
|
|||
|
|
@ -222,25 +222,10 @@ stub_dlz_create(const char *dlzname, unsigned int argc, char *argv[],
|
|||
memset(cd, 0, sizeof(config_data_t));
|
||||
|
||||
cd->myzone = isc_mem_strdup(named_g_mctx, argv[1]);
|
||||
if (cd->myzone == NULL) {
|
||||
isc_mem_put(named_g_mctx, cd, sizeof(config_data_t));
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
cd->myname = isc_mem_strdup(named_g_mctx, argv[2]);
|
||||
if (cd->myname == NULL) {
|
||||
isc_mem_put(named_g_mctx, cd, sizeof(config_data_t));
|
||||
isc_mem_free(named_g_mctx, cd->myzone);
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
cd->myip = isc_mem_strdup(named_g_mctx, argv[3]);
|
||||
if (cd->myip == NULL) {
|
||||
isc_mem_put(named_g_mctx, cd, sizeof(config_data_t));
|
||||
isc_mem_free(named_g_mctx, cd->myname);
|
||||
isc_mem_free(named_g_mctx, cd->myzone);
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
isc_mem_attach(named_g_mctx, &cd->mctx);
|
||||
|
||||
|
|
|
|||
|
|
@ -158,11 +158,6 @@ build_querylist(isc_mem_t *mctx, const char *query_str, char **zone,
|
|||
ISC_LIST_APPEND(*tql, tseg, link);
|
||||
|
||||
tseg->sql = isc_mem_strdup(mctx, sql);
|
||||
if (tseg->sql == NULL) {
|
||||
/* no memory, clean everything up. */
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto cleanup;
|
||||
}
|
||||
/* tseg->sql points directly to a string. */
|
||||
tseg->direct = true;
|
||||
tseg->strlen = strlen(tseg->sql);
|
||||
|
|
|
|||
|
|
@ -379,8 +379,6 @@ nameexist(const cfg_obj_t *obj, const char *name, int value,
|
|||
isc_symvalue_t symvalue;
|
||||
|
||||
key = isc_mem_strdup(mctx, name);
|
||||
if (key == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
symvalue.as_cpointer = obj;
|
||||
result = isc_symtab_define(symtab, key, value, symvalue,
|
||||
isc_symexists_reject);
|
||||
|
|
@ -2127,20 +2125,17 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
|
|||
case CFG_ZONE_STUB:
|
||||
case CFG_ZONE_STATICSTUB:
|
||||
tmp = isc_mem_strdup(mctx, namebuf);
|
||||
if (tmp != NULL) {
|
||||
{
|
||||
isc_symvalue_t symvalue;
|
||||
|
||||
symvalue.as_cpointer = NULL;
|
||||
tresult = isc_symtab_define(inview, tmp, 1,
|
||||
symvalue, isc_symexists_replace);
|
||||
symvalue,
|
||||
isc_symexists_replace);
|
||||
if (tresult == ISC_R_NOMEMORY) {
|
||||
isc_mem_free(mctx, tmp);
|
||||
}
|
||||
if (result == ISC_R_SUCCESS &&
|
||||
tresult != ISC_R_SUCCESS)
|
||||
if (result == ISC_R_SUCCESS && tresult != ISC_R_SUCCESS)
|
||||
result = tresult;
|
||||
} else if (result != ISC_R_SUCCESS) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -2878,8 +2873,6 @@ check_keylist(const cfg_obj_t *keys, isc_symtab_t *symtab,
|
|||
|
||||
dns_name_format(name, namebuf, sizeof(namebuf));
|
||||
keyname = isc_mem_strdup(mctx, namebuf);
|
||||
if (keyname == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
symvalue.as_cpointer = key;
|
||||
tresult = isc_symtab_define(symtab, keyname, 1, symvalue,
|
||||
isc_symexists_reject);
|
||||
|
|
|
|||
|
|
@ -204,10 +204,6 @@ dns_cache_create(isc_mem_t *cmctx, isc_mem_t *hmctx, isc_taskmgr_t *taskmgr,
|
|||
cache->name = NULL;
|
||||
if (cachename != NULL) {
|
||||
cache->name = isc_mem_strdup(cmctx, cachename);
|
||||
if (cache->name == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto cleanup_mem;
|
||||
}
|
||||
}
|
||||
|
||||
isc_mutex_init(&cache->lock);
|
||||
|
|
@ -225,10 +221,6 @@ dns_cache_create(isc_mem_t *cmctx, isc_mem_t *hmctx, isc_taskmgr_t *taskmgr,
|
|||
goto cleanup_filelock;
|
||||
|
||||
cache->db_type = isc_mem_strdup(cmctx, db_type);
|
||||
if (cache->db_type == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto cleanup_stats;
|
||||
}
|
||||
|
||||
/*
|
||||
* For databases of type "rbt" we pass hmctx to dns_db_create()
|
||||
|
|
@ -252,10 +244,6 @@ dns_cache_create(isc_mem_t *cmctx, isc_mem_t *hmctx, isc_taskmgr_t *taskmgr,
|
|||
for (i = extra; i < cache->db_argc; i++) {
|
||||
cache->db_argv[i] = isc_mem_strdup(cmctx,
|
||||
db_argv[i - extra]);
|
||||
if (cache->db_argv[i] == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto cleanup_dbargv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -462,8 +450,6 @@ dns_cache_setfilename(dns_cache_t *cache, const char *filename) {
|
|||
REQUIRE(filename != NULL);
|
||||
|
||||
newname = isc_mem_strdup(cache->mctx, filename);
|
||||
if (newname == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
|
||||
LOCK(&cache->filelock);
|
||||
if (cache->filename)
|
||||
|
|
|
|||
|
|
@ -440,9 +440,7 @@ toregion(dns_dtenv_t *env, isc_region_t *r, const char *str) {
|
|||
REQUIRE(r != NULL);
|
||||
|
||||
if (str != NULL) {
|
||||
p = (unsigned char *) isc_mem_strdup(env->mctx, str);
|
||||
if (p == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
p = (unsigned char *)isc_mem_strdup(env->mctx, str);
|
||||
}
|
||||
|
||||
if (r->base != NULL) {
|
||||
|
|
|
|||
|
|
@ -168,8 +168,6 @@ load_library(isc_mem_t *mctx, const char *filename, const char *instname,
|
|||
imp->register_func = register_func;
|
||||
imp->destroy_func = destroy_func;
|
||||
imp->name = isc_mem_strdup(mctx, instname);
|
||||
if (imp->name == NULL)
|
||||
CHECK(ISC_R_NOMEMORY);
|
||||
|
||||
imp->inst = NULL;
|
||||
INIT_LINK(imp, link);
|
||||
|
|
@ -282,8 +280,6 @@ load_library(isc_mem_t *mctx, const char *filename, const char *instname,
|
|||
imp->register_func = register_func;
|
||||
imp->destroy_func = destroy_func;
|
||||
imp->name = isc_mem_strdup(mctx, instname);
|
||||
if (imp->name == NULL)
|
||||
CHECK(ISC_R_NOMEMORY);
|
||||
|
||||
imp->inst = NULL;
|
||||
INIT_LINK(imp, link);
|
||||
|
|
|
|||
|
|
@ -959,8 +959,6 @@ check_ns(dns_loadctx_t *lctx, isc_token_t *token, const char *source,
|
|||
struct in6_addr addr6;
|
||||
|
||||
tmp = isc_mem_strdup(lctx->mctx, DNS_AS_STR(*token));
|
||||
if (tmp == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
/*
|
||||
* Catch both "1.2.3.4" and "1.2.3.4."
|
||||
*/
|
||||
|
|
@ -1189,11 +1187,7 @@ load_text(dns_loadctx_t *lctx) {
|
|||
if (include_file != NULL)
|
||||
isc_mem_free(mctx, include_file);
|
||||
include_file = isc_mem_strdup(mctx,
|
||||
DNS_AS_STR(token));
|
||||
if (include_file == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto log_and_cleanup;
|
||||
}
|
||||
DNS_AS_STR(token));
|
||||
GETTOKEN(lctx->lex, 0, &token, true);
|
||||
|
||||
if (token.type == isc_tokentype_eol ||
|
||||
|
|
@ -1275,18 +1269,10 @@ load_text(dns_loadctx_t *lctx) {
|
|||
/* RANGE */
|
||||
GETTOKEN(lctx->lex, 0, &token, false);
|
||||
range = isc_mem_strdup(mctx,
|
||||
DNS_AS_STR(token));
|
||||
if (range == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto log_and_cleanup;
|
||||
}
|
||||
DNS_AS_STR(token));
|
||||
/* LHS */
|
||||
GETTOKEN(lctx->lex, 0, &token, false);
|
||||
lhs = isc_mem_strdup(mctx, DNS_AS_STR(token));
|
||||
if (lhs == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto log_and_cleanup;
|
||||
}
|
||||
rdclass = 0;
|
||||
explicit_ttl = false;
|
||||
/* CLASS? */
|
||||
|
|
@ -1318,18 +1304,10 @@ load_text(dns_loadctx_t *lctx) {
|
|||
/* TYPE */
|
||||
gtype = isc_mem_strdup(mctx,
|
||||
DNS_AS_STR(token));
|
||||
if (gtype == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto log_and_cleanup;
|
||||
}
|
||||
/* RHS */
|
||||
GETTOKEN(lctx->lex, ISC_LEXOPT_QSTRING,
|
||||
&token, false);
|
||||
rhs = isc_mem_strdup(mctx, DNS_AS_STR(token));
|
||||
if (rhs == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto log_and_cleanup;
|
||||
}
|
||||
if (!lctx->ttl_known &&
|
||||
!lctx->default_ttl_known) {
|
||||
(*callbacks->error)(callbacks,
|
||||
|
|
|
|||
|
|
@ -1843,8 +1843,6 @@ dns_master_dumpinc(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
|
|||
dns_dumpctx_t *dctx = NULL;
|
||||
|
||||
file = isc_mem_strdup(mctx, filename);
|
||||
if (file == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
|
||||
result = opentmp(mctx, format, filename, &tempname, &f);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
|
|
|
|||
|
|
@ -901,11 +901,7 @@ opensslrsa_parse(dst_key_t *key, isc_lex_t *lexer, dst_key_t *pub) {
|
|||
"ENGINE_load_private_key",
|
||||
ISC_R_NOTFOUND));
|
||||
key->engine = isc_mem_strdup(key->mctx, engine);
|
||||
if (key->engine == NULL)
|
||||
DST_RET(ISC_R_NOMEMORY);
|
||||
key->label = isc_mem_strdup(key->mctx, label);
|
||||
if (key->label == NULL)
|
||||
DST_RET(ISC_R_NOMEMORY);
|
||||
rsa = EVP_PKEY_get1_RSA(pkey);
|
||||
if (rsa == NULL)
|
||||
DST_RET(dst__openssl_toresult(DST_R_OPENSSLFAILURE));
|
||||
|
|
@ -1038,8 +1034,6 @@ opensslrsa_fromlabel(dst_key_t *key, const char *engine, const char *label,
|
|||
if (strchr(label, ':') == NULL)
|
||||
DST_RET(DST_R_NOENGINE);
|
||||
tmpengine = isc_mem_strdup(key->mctx, label);
|
||||
if (tmpengine == NULL)
|
||||
DST_RET(ISC_R_NOMEMORY);
|
||||
colon = strchr(tmpengine, ':');
|
||||
INSIST(colon != NULL);
|
||||
*colon = '\0';
|
||||
|
|
@ -1063,12 +1057,8 @@ opensslrsa_fromlabel(dst_key_t *key, const char *engine, const char *label,
|
|||
tmpengine = NULL;
|
||||
} else {
|
||||
key->engine = isc_mem_strdup(key->mctx, engine);
|
||||
if (key->engine == NULL)
|
||||
DST_RET(ISC_R_NOMEMORY);
|
||||
}
|
||||
key->label = isc_mem_strdup(key->mctx, label);
|
||||
if (key->label == NULL)
|
||||
DST_RET(ISC_R_NOMEMORY);
|
||||
rsa = EVP_PKEY_get1_RSA(pkey);
|
||||
if (rsa == NULL)
|
||||
DST_RET(dst__openssl_toresult(DST_R_OPENSSLFAILURE));
|
||||
|
|
|
|||
|
|
@ -841,13 +841,9 @@ pkcs11ecdsa_fetch(dst_key_t *key, const char *engine, const char *label,
|
|||
|
||||
if (engine != NULL) {
|
||||
key->engine = isc_mem_strdup(key->mctx, engine);
|
||||
if (key->engine == NULL)
|
||||
DST_RET(ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
key->label = isc_mem_strdup(key->mctx, label);
|
||||
if (key->label == NULL)
|
||||
DST_RET(ISC_R_NOMEMORY);
|
||||
|
||||
pk11_return_session(pk11_ctx);
|
||||
memset(pk11_ctx, 0, sizeof(*pk11_ctx));
|
||||
|
|
@ -1062,13 +1058,9 @@ pkcs11ecdsa_fromlabel(dst_key_t *key, const char *engine, const char *label,
|
|||
|
||||
if (engine != NULL) {
|
||||
key->engine = isc_mem_strdup(key->mctx, engine);
|
||||
if (key->engine == NULL)
|
||||
DST_RET(ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
key->label = isc_mem_strdup(key->mctx, label);
|
||||
if (key->label == NULL)
|
||||
DST_RET(ISC_R_NOMEMORY);
|
||||
if (key->key_alg == DST_ALG_ECDSA256)
|
||||
key->key_size = DNS_KEY_ECDSA256SIZE * 4;
|
||||
else
|
||||
|
|
|
|||
|
|
@ -821,13 +821,9 @@ pkcs11eddsa_fetch(dst_key_t *key, const char *engine, const char *label,
|
|||
|
||||
if (engine != NULL) {
|
||||
key->engine = isc_mem_strdup(key->mctx, engine);
|
||||
if (key->engine == NULL)
|
||||
DST_RET(ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
key->label = isc_mem_strdup(key->mctx, label);
|
||||
if (key->label == NULL)
|
||||
DST_RET(ISC_R_NOMEMORY);
|
||||
|
||||
pk11_return_session(pk11_ctx);
|
||||
memset(pk11_ctx, 0, sizeof(*pk11_ctx));
|
||||
|
|
@ -1043,13 +1039,9 @@ pkcs11eddsa_fromlabel(dst_key_t *key, const char *engine, const char *label,
|
|||
|
||||
if (engine != NULL) {
|
||||
key->engine = isc_mem_strdup(key->mctx, engine);
|
||||
if (key->engine == NULL)
|
||||
DST_RET(ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
key->label = isc_mem_strdup(key->mctx, label);
|
||||
if (key->label == NULL)
|
||||
DST_RET(ISC_R_NOMEMORY);
|
||||
if (key->key_alg == DST_ALG_ED25519)
|
||||
key->key_size = DNS_KEY_ED25519SIZE;
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1643,13 +1643,9 @@ pkcs11rsa_fetch(dst_key_t *key, const char *engine, const char *label,
|
|||
|
||||
if (engine != NULL) {
|
||||
key->engine = isc_mem_strdup(key->mctx, engine);
|
||||
if (key->engine == NULL)
|
||||
DST_RET(ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
key->label = isc_mem_strdup(key->mctx, label);
|
||||
if (key->label == NULL)
|
||||
DST_RET(ISC_R_NOMEMORY);
|
||||
|
||||
pk11_return_session(pk11_ctx);
|
||||
isc_safe_memwipe(pk11_ctx, sizeof(*pk11_ctx));
|
||||
|
|
@ -1995,13 +1991,9 @@ pkcs11rsa_fromlabel(dst_key_t *key, const char *engine, const char *label,
|
|||
|
||||
if (engine != NULL) {
|
||||
key->engine = isc_mem_strdup(key->mctx, engine);
|
||||
if (key->engine == NULL)
|
||||
DST_RET(ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
key->label = isc_mem_strdup(key->mctx, label);
|
||||
if (key->label == NULL)
|
||||
DST_RET(ISC_R_NOMEMORY);
|
||||
|
||||
attr = pk11_attribute_bytype(rsa, CKA_PUBLIC_EXPONENT);
|
||||
INSIST(attr != NULL);
|
||||
|
|
|
|||
|
|
@ -4715,10 +4715,6 @@ fctx_create(dns_resolver_t *res, const dns_name_t *name, dns_rdatatype_t type,
|
|||
strlcat(buf, "/", sizeof(buf));
|
||||
strlcat(buf, typebuf, sizeof(buf));
|
||||
fctx->info = isc_mem_strdup(mctx, buf);
|
||||
if (fctx->info == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto cleanup_counter;
|
||||
}
|
||||
|
||||
FCTXTRACE("create");
|
||||
dns_name_init(&fctx->name, NULL);
|
||||
|
|
|
|||
|
|
@ -1293,10 +1293,6 @@ dns_sdb_create(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
|
|||
isc_buffer_putuint8(&b, 0);
|
||||
|
||||
sdb->zone = isc_mem_strdup(mctx, zonestr);
|
||||
if (sdb->zone == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto cleanup_origin;
|
||||
}
|
||||
|
||||
sdb->dbdata = NULL;
|
||||
if (imp->methods->create != NULL) {
|
||||
|
|
|
|||
|
|
@ -96,20 +96,12 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
|
|||
view->mctx = NULL;
|
||||
isc_mem_attach(mctx, &view->mctx);
|
||||
view->name = isc_mem_strdup(mctx, name);
|
||||
if (view->name == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto cleanup_view;
|
||||
}
|
||||
|
||||
result = isc_file_sanitize(NULL, view->name, "nta",
|
||||
buffer, sizeof(buffer));
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup_name;
|
||||
view->nta_file = isc_mem_strdup(mctx, buffer);
|
||||
if (view->nta_file == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto cleanup_name;
|
||||
}
|
||||
|
||||
isc_mutex_init(&view->lock);
|
||||
|
||||
|
|
@ -2084,18 +2076,12 @@ dns_view_setnewzones(dns_view_t *view, bool allow, void *cfgctx,
|
|||
buffer, sizeof(buffer)));
|
||||
|
||||
view->new_zone_file = isc_mem_strdup(view->mctx, buffer);
|
||||
if (view->new_zone_file == NULL) {
|
||||
CHECK(ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
#ifdef HAVE_LMDB
|
||||
CHECK(nz_legacy(view->new_zone_dir, view->name, "nzd",
|
||||
buffer, sizeof(buffer)));
|
||||
|
||||
view->new_zone_db = isc_mem_strdup(view->mctx, buffer);
|
||||
if (view->new_zone_db == NULL) {
|
||||
CHECK(ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
status = mdb_env_create(&env);
|
||||
if (status != MDB_SUCCESS) {
|
||||
|
|
|
|||
|
|
@ -1459,8 +1459,6 @@ dns_zone_setdbtype(dns_zone_t *zone,
|
|||
}
|
||||
for (i = 0; i < dbargc; i++) {
|
||||
argv[i] = isc_mem_strdup(zone->mctx, dbargv[i]);
|
||||
if (argv[i] == NULL)
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
/* Free the old list. */
|
||||
|
|
@ -1594,8 +1592,6 @@ dns_zone_setstring(dns_zone_t *zone, char **field, const char *value) {
|
|||
|
||||
if (value != NULL) {
|
||||
copy = isc_mem_strdup(zone->mctx, value);
|
||||
if (copy == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
} else {
|
||||
copy = NULL;
|
||||
}
|
||||
|
|
@ -2360,10 +2356,6 @@ zone_registerinclude(const char *filename, void *arg) {
|
|||
|
||||
inc = isc_mem_get(zone->mctx, sizeof(dns_include_t));
|
||||
inc->name = isc_mem_strdup(zone->mctx, filename);
|
||||
if (inc->name == NULL) {
|
||||
isc_mem_put(zone->mctx, inc, sizeof(dns_include_t));
|
||||
return;
|
||||
}
|
||||
ISC_LINK_INIT(inc, link);
|
||||
|
||||
result = isc_file_getmodtime(filename, &inc->filetime);
|
||||
|
|
|
|||
|
|
@ -326,8 +326,6 @@ resconf_parsedomain(irs_resconf_t *conf, FILE *fp) {
|
|||
conf->searchnxt = 0;
|
||||
|
||||
conf->domainname = isc_mem_strdup(conf->mctx, word);
|
||||
if (conf->domainname == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
|
@ -368,8 +366,6 @@ resconf_parsesearch(irs_resconf_t *conf, FILE *fp) {
|
|||
|
||||
INSIST(idx < sizeof(conf->search)/sizeof(conf->search[0]));
|
||||
conf->search[idx] = isc_mem_strdup(conf->mctx, word);
|
||||
if (conf->search[idx] == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
idx++;
|
||||
conf->searchnxt++;
|
||||
|
||||
|
|
|
|||
|
|
@ -1196,10 +1196,6 @@ isc_httpdmgr_addurl2(isc_httpdmgr_t *httpdmgr, const char *url,
|
|||
item = isc_mem_get(httpdmgr->mctx, sizeof(isc_httpdurl_t));
|
||||
|
||||
item->url = isc_mem_strdup(httpdmgr->mctx, url);
|
||||
if (item->url == NULL) {
|
||||
isc_mem_put(httpdmgr->mctx, item, sizeof(isc_httpdurl_t));
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
item->action = func;
|
||||
item->action_arg = arg;
|
||||
|
|
|
|||
|
|
@ -191,10 +191,6 @@ new_source(isc_lex_t *lex, bool is_file, bool need_close,
|
|||
source->last_was_eol = lex->last_was_eol;
|
||||
source->input = input;
|
||||
source->name = isc_mem_strdup(lex->mctx, name);
|
||||
if (source->name == NULL) {
|
||||
isc_mem_put(lex->mctx, source, sizeof(*source));
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
source->pushback = NULL;
|
||||
result = isc_buffer_allocate(lex->mctx, &source->pushback,
|
||||
(unsigned int)lex->max_token);
|
||||
|
|
@ -1000,8 +996,6 @@ isc_lex_setsourcename(isc_lex_t *lex, const char *name) {
|
|||
if (source == NULL)
|
||||
return (ISC_R_NOTFOUND);
|
||||
newname = isc_mem_strdup(lex->mctx, name);
|
||||
if (newname == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
isc_mem_free(lex->mctx, source->name);
|
||||
source->name = newname;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
|
|
|||
|
|
@ -702,10 +702,6 @@ isc_log_createchannel(isc_logconfig_t *lcfg, const char *name,
|
|||
channel = isc_mem_get(mctx, sizeof(*channel));
|
||||
|
||||
channel->name = isc_mem_strdup(mctx, name);
|
||||
if (channel->name == NULL) {
|
||||
isc_mem_put(mctx, channel, sizeof(*channel));
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
channel->type = type;
|
||||
channel->level = level;
|
||||
|
|
@ -723,8 +719,8 @@ isc_log_createchannel(isc_logconfig_t *lcfg, const char *name,
|
|||
* to scribble on it, so it needs to be definitely in
|
||||
* writable memory.
|
||||
*/
|
||||
FILE_NAME(channel) =
|
||||
isc_mem_strdup(mctx, destination->file.name);
|
||||
FILE_NAME(channel) = isc_mem_strdup(mctx,
|
||||
destination->file.name);
|
||||
FILE_STREAM(channel) = NULL;
|
||||
FILE_VERSIONS(channel) = destination->file.versions;
|
||||
FILE_SUFFIX(channel) = destination->file.suffix;
|
||||
|
|
@ -920,8 +916,6 @@ isc_log_settag(isc_logconfig_t *lcfg, const char *tag) {
|
|||
if (lcfg->tag != NULL)
|
||||
isc_mem_free(lcfg->lctx->mctx, lcfg->tag);
|
||||
lcfg->tag = isc_mem_strdup(lcfg->lctx->mctx, tag);
|
||||
if (lcfg->tag == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
|
||||
} else {
|
||||
if (lcfg->tag != NULL)
|
||||
|
|
|
|||
|
|
@ -171,8 +171,6 @@ convert_named_acl(const cfg_obj_t *nameobj, const cfg_obj_t *cctx,
|
|||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
dacl->name = isc_mem_strdup(dacl->mctx, aclname);
|
||||
if (dacl->name == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
ISC_LIST_APPEND(ctx->named_acl_cache, dacl, nextincache);
|
||||
dns_acl_attach(dacl, target);
|
||||
return (ISC_R_SUCCESS);
|
||||
|
|
|
|||
|
|
@ -195,8 +195,6 @@ ns_server_setserverid(ns_server_t *sctx, const char *serverid) {
|
|||
|
||||
if (serverid != NULL) {
|
||||
sctx->server_id = isc_mem_strdup(sctx->mctx, serverid);
|
||||
if (sctx->server_id == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
|
|
|
|||
|
|
@ -956,11 +956,6 @@ probe_domain(struct probe_trans *trans) {
|
|||
if ((cp = strchr(buf, '\n')) != NULL) /* zap NL if any */
|
||||
*cp = '\0';
|
||||
trans->domain = isc_mem_strdup(mctx, buf);
|
||||
if (trans->domain == NULL) {
|
||||
fprintf(stderr,
|
||||
"failed to allocate memory for domain: %s", cp);
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
/* Start getting NS for the domain */
|
||||
domainlen = strlen(buf);
|
||||
|
|
|
|||
Loading…
Reference in a new issue