result = dns_message_gettempname(lookup->sendmsg, &soaname);
check_result(result, "dns_message_gettempname");
- dns_name_init(soaname, NULL);
dns_name_clone(lookup->name, soaname);
ISC_LIST_INIT(soaname->list);
ISC_LIST_APPEND(soaname->list, rdataset, link);
}
result = dns_message_gettempname(lookup->sendmsg, &lookup->name);
check_result(result, "dns_message_gettempname");
- dns_name_init(lookup->name, NULL);
isc_buffer_init(&lookup->namebuf, lookup->name_space,
sizeof(lookup->name_space));
result = dns_message_gettempname(lookup->sendmsg,
&lookup->oname);
check_result(result, "dns_message_gettempname");
- dns_name_init(lookup->oname, NULL);
/* XXX Helper funct to conv char* to name? */
origin = lookup->origin->origin;
#ifdef HAVE_LIBIDN2
parse_name(char **cmdlinep, dns_message_t *msg, dns_name_t **namep) {
isc_result_t result;
char *word;
- isc_buffer_t *namebuf = NULL;
isc_buffer_t source;
word = nsu_strsep(cmdlinep, " \t\r\n");
result = dns_message_gettempname(msg, namep);
check_result(result, "dns_message_gettempname");
- isc_buffer_allocate(gmctx, &namebuf, DNS_NAME_MAXWIRE);
- dns_name_init(*namep, NULL);
- dns_name_setbuffer(*namep, namebuf);
- dns_message_takebuffer(msg, &namebuf);
isc_buffer_init(&source, word, strlen(word));
isc_buffer_add(&source, strlen(word));
result = dns_name_fromtext(*namep, &source, dns_rootname, 0, NULL);
if (zonename != NULL) {
result = dns_message_gettempname(updatemsg, &name);
check_result(result, "dns_message_gettempname");
- dns_name_init(name, NULL);
dns_name_clone(zonename, name);
result = dns_message_gettemprdataset(updatemsg, &rdataset);
check_result(result, "dns_message_gettemprdataset");
dns_rdataset_makequestion(rdataset, getzoneclass(), dns_rdatatype_soa);
if (userzone != NULL) {
- dns_name_init(name, NULL);
dns_name_clone(userzone, name);
} else {
dns_rdataset_t *tmprdataset;
}
firstname = NULL;
dns_message_currentname(updatemsg, section, &firstname);
- dns_name_init(name, NULL);
dns_name_clone(firstname, name);
/*
* Looks to see if the first name references a DS record
result = dns_message_gettemprdataset(message, &qrdataset);
CHECK("dns_message_gettemprdataset", result);
- dns_name_init(qname, NULL);
dns_name_clone(dns_fixedname_name(&queryname), qname);
dns_rdataset_makequestion(qrdataset, dns_rdataclass_in,
dns_rdatatype_a);
#define US_PER_SEC 1000000 /*%< Microseconds per second. */
#define US_PER_MS 1000 /*%< Microseconds per millisecond. */
-static isc_mem_t *mctx;
-static dns_requestmgr_t *requestmgr;
-static const char *batchname;
-static FILE *batchfp;
+static isc_mem_t *mctx = NULL;
+static dns_requestmgr_t *requestmgr = NULL;
+static const char *batchname = NULL;
+static FILE *batchfp = NULL;
static bool burst = false;
static bool have_ipv4 = false;
static bool have_ipv6 = false;
static bool continue_on_error = false;
static uint32_t display_splitwidth = 0xffffffff;
static isc_sockaddr_t srcaddr;
-static char *server;
+static char *server = NULL;
static isc_sockaddr_t dstaddr;
static in_port_t port = 53;
static isc_dscp_t dscp = -1;
static isc_result_t
sendquery(struct query *query, isc_task_t *task) {
- dns_request_t *request;
- dns_message_t *message;
- dns_name_t *qname;
- dns_rdataset_t *qrdataset;
+ dns_request_t *request = NULL;
+ dns_message_t *message = NULL;
+ dns_name_t *qname = NULL;
+ dns_rdataset_t *qrdataset = NULL;
isc_result_t result;
dns_fixedname_t queryname;
isc_buffer_t buf;
dns_rootname, 0, NULL);
CHECK("dns_name_fromtext", result);
- message = NULL;
dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &message);
message->opcode = dns_opcode_query;
message->rdclass = query->rdclass;
message->id = (unsigned short)(random() & 0xFFFF);
- qname = NULL;
result = dns_message_gettempname(message, &qname);
CHECK("dns_message_gettempname", result);
- qrdataset = NULL;
result = dns_message_gettemprdataset(message, &qrdataset);
CHECK("dns_message_gettemprdataset", result);
- dns_name_init(qname, NULL);
dns_name_clone(dns_fixedname_name(&queryname), qname);
dns_rdataset_makequestion(qrdataset, query->rdclass, query->rdtype);
ISC_LIST_APPEND(qname->list, qrdataset, link);
/*% Main processing routine for mdig */
int
main(int argc, char *argv[]) {
- struct query *query;
+ struct query *query = NULL;
isc_result_t result;
isc_sockaddr_t bind_any;
- isc_log_t *lctx;
- isc_logconfig_t *lcfg;
+ isc_log_t *lctx = NULL;
+ isc_logconfig_t *lcfg = NULL;
isc_nm_t *netmgr = NULL;
isc_taskmgr_t *taskmgr = NULL;
isc_task_t *task = NULL;
isc_socketmgr_t *socketmgr = NULL;
dns_dispatchmgr_t *dispatchmgr = NULL;
unsigned int attrs, attrmask;
- dns_dispatch_t *dispatchvx;
- dns_view_t *view;
+ dns_dispatch_t *dispatchvx = NULL;
+ dns_view_t *view = NULL;
int ns;
unsigned int i;
preparse_args(argc, argv);
- mctx = NULL;
isc_mem_create(&mctx);
- lctx = NULL;
- lcfg = NULL;
isc_log_create(mctx, &lctx, &lcfg);
RUNCHECK(dst_lib_init(mctx, NULL));
have_src ? &srcaddr : &bind_any, 4096, 100,
100, 17, 19, attrs, attrmask,
&dispatchvx));
- requestmgr = NULL;
+
RUNCHECK(dns_requestmgr_create(
mctx, timermgr, socketmgr, taskmgr, dispatchmgr,
have_ipv4 ? dispatchvx : NULL, have_ipv6 ? dispatchvx : NULL,
&requestmgr));
- view = NULL;
RUNCHECK(dns_view_create(mctx, 0, "_test", &view));
query = ISC_LIST_HEAD(queries);
* \code
* buffer = isc_buffer_allocate(mctx, 512);
* name = NULL;
- * name = dns_message_gettempname(message, &name);
- * dns_name_init(name, NULL);
+ * result = dns_message_gettempname(message, &name);
* result = dns_name_fromtext(name, &source, dns_rootname, 0, buffer);
* dns_message_takebuffer(message, &buffer);
* \endcode
* to the message code using dns_message_puttempname() or inserted into
* one of the message's sections before the message is destroyed.
*
- * It is the caller's responsibility to initialize this name.
- *
- * Requires:
- *\li msg be a valid message
- *
- *\li item != NULL && *item == NULL
- *
- * Returns:
- *\li #ISC_R_SUCCESS -- All is well.
- *\li #ISC_R_NOMEMORY -- No item can be allocated.
- */
-
-isc_result_t
-dns_message_gettempoffsets(dns_message_t *msg, dns_offsets_t **item);
-/*%<
- * Return an offsets array that can be used for any temporary purpose,
- * such as attaching to a temporary name. The offsets will be freed
- * when the message is destroyed or reset.
+ * The name will be associated with a dns_fixedname object, and will
+ * be initialized.
*
* Requires:
*\li msg be a valid message
isc_mempool_put(msg->rdspool, rds);
rds = next_rds;
}
- if (dns_name_dynamic(name)) {
- dns_name_free(name, msg->mctx);
- }
- isc_mempool_put(msg->namepool, name);
+ dns_message_puttempname(msg, &name);
name = next_name;
}
}
isc_mempool_put(msg->rdspool, msg->querytsig);
}
}
- if (dns_name_dynamic(msg->tsigname)) {
- dns_name_free(msg->tsigname, msg->mctx);
- }
- isc_mempool_put(msg->namepool, msg->tsigname);
+ dns_message_puttempname(msg, &msg->tsigname);
msg->tsig = NULL;
- msg->tsigname = NULL;
} else if (msg->querytsig != NULL && !replying) {
dns_rdataset_disassociate(msg->querytsig);
isc_mempool_put(msg->rdspool, msg->querytsig);
msg->sig0 = NULL;
}
if (msg->sig0name != NULL) {
- if (dns_name_dynamic(msg->sig0name)) {
- dns_name_free(msg->sig0name, msg->mctx);
- }
- isc_mempool_put(msg->namepool, msg->sig0name);
- msg->sig0name = NULL;
+ dns_message_puttempname(msg, &msg->sig0name);
}
}
void
dns_message_create(isc_mem_t *mctx, unsigned int intent, dns_message_t **msgp) {
- dns_message_t *m;
- isc_buffer_t *dynbuf;
+ dns_message_t *m = NULL;
+ isc_buffer_t *dynbuf = NULL;
unsigned int i;
REQUIRE(mctx != NULL);
intent == DNS_MESSAGE_INTENTRENDER);
m = isc_mem_get(mctx, sizeof(dns_message_t));
-
- m->magic = DNS_MESSAGE_MAGIC;
- m->from_to_wire = intent;
+ *m = (dns_message_t){ .from_to_wire = intent };
+ isc_mem_attach(mctx, &m->mctx);
msginit(m);
for (i = 0; i < DNS_SECTION_MAX; i++) {
ISC_LIST_INIT(m->sections[i]);
}
- m->mctx = NULL;
- isc_mem_attach(mctx, &m->mctx);
-
ISC_LIST_INIT(m->scratchpad);
ISC_LIST_INIT(m->cleanup);
- m->namepool = NULL;
- m->rdspool = NULL;
ISC_LIST_INIT(m->rdatas);
ISC_LIST_INIT(m->rdatalists);
ISC_LIST_INIT(m->offsets);
ISC_LIST_INIT(m->freerdata);
ISC_LIST_INIT(m->freerdatalist);
- isc_mempool_create(m->mctx, sizeof(dns_name_t), &m->namepool);
+ isc_mempool_create(m->mctx, sizeof(dns_fixedname_t), &m->namepool);
isc_mempool_setfillcount(m->namepool, NAME_COUNT);
isc_mempool_setfreemax(m->namepool, NAME_COUNT);
isc_mempool_setname(m->namepool, "msg:names");
isc_mempool_setfreemax(m->rdspool, RDATASET_COUNT);
isc_mempool_setname(m->rdspool, "msg:rdataset");
- dynbuf = NULL;
isc_buffer_allocate(mctx, &dynbuf, SCRATCHPAD_SIZE);
ISC_LIST_APPEND(m->scratchpad, dynbuf, link);
- m->cctx = NULL;
-
isc_refcount_init(&m->refcount, 1);
+ m->magic = DNS_MESSAGE_MAGIC;
*msgp = m;
}
unsigned int options) {
isc_region_t r;
unsigned int count;
- dns_name_t *name;
- dns_name_t *name2;
- dns_offsets_t *offsets;
- dns_rdataset_t *rdataset;
- dns_rdatalist_t *rdatalist;
+ dns_name_t *name = NULL;
+ dns_name_t *name2 = NULL;
+ dns_rdataset_t *rdataset = NULL;
+ dns_rdatalist_t *rdatalist = NULL;
isc_result_t result;
dns_rdatatype_t rdtype;
dns_rdataclass_t rdclass;
- dns_namelist_t *section;
- bool free_name;
- bool best_effort;
- bool seen_problem;
-
- section = &msg->sections[DNS_SECTION_QUESTION];
-
- best_effort = ((options & DNS_MESSAGEPARSE_BESTEFFORT) != 0);
- seen_problem = false;
-
- name = NULL;
- rdataset = NULL;
- rdatalist = NULL;
+ dns_namelist_t *section = &msg->sections[DNS_SECTION_QUESTION];
+ bool best_effort = ((options & DNS_MESSAGEPARSE_BESTEFFORT) != 0);
+ bool seen_problem = false;
+ bool free_name = false;
for (count = 0; count < msg->counts[DNS_SECTION_QUESTION]; count++) {
- name = isc_mempool_get(msg->namepool);
- if (name == NULL) {
- return (ISC_R_NOMEMORY);
- }
- free_name = true;
-
- offsets = newoffsets(msg);
- if (offsets == NULL) {
- result = ISC_R_NOMEMORY;
+ name = NULL;
+ result = dns_message_gettempname(msg, &name);
+ if (result != ISC_R_SUCCESS) {
goto cleanup;
}
- dns_name_init(name, *offsets);
+ name->offsets = (unsigned char *)newoffsets(msg);
+ free_name = true;
/*
* Parse the name out of this packet.
ISC_LIST_APPEND(*section, name, link);
free_name = false;
} else {
- isc_mempool_put(msg->namepool, name);
+ dns_message_puttempname(msg, &name);
name = name2;
name2 = NULL;
free_name = false;
INSIST(!dns_rdataset_isassociated(rdataset));
isc_mempool_put(msg->rdspool, rdataset);
}
-#if 0
- if (rdatalist != NULL) {
- isc_mempool_put(msg->rdlpool, rdatalist);
- }
-#endif /* if 0 */
if (free_name) {
- isc_mempool_put(msg->namepool, name);
+ dns_message_puttempname(msg, &name);
}
return (result);
unsigned int count, rdatalen;
dns_name_t *name = NULL;
dns_name_t *name2 = NULL;
- dns_offsets_t *offsets;
- dns_rdataset_t *rdataset;
- dns_rdatalist_t *rdatalist;
+ dns_rdataset_t *rdataset = NULL;
+ dns_rdatalist_t *rdatalist = NULL;
isc_result_t result;
dns_rdatatype_t rdtype, covers;
dns_rdataclass_t rdclass;
- dns_rdata_t *rdata;
+ dns_rdata_t *rdata = NULL;
dns_ttl_t ttl;
- dns_namelist_t *section;
- bool free_name = false, free_rdataset = false;
- bool preserve_order, best_effort, seen_problem;
+ dns_namelist_t *section = &msg->sections[sectionid];
+ bool free_name = false, free_rdataset = false, seen_problem = false;
+ bool preserve_order = ((options & DNS_MESSAGEPARSE_PRESERVEORDER) != 0);
+ bool best_effort = ((options & DNS_MESSAGEPARSE_BESTEFFORT) != 0);
bool isedns, issigzero, istsig;
- preserve_order = ((options & DNS_MESSAGEPARSE_PRESERVEORDER) != 0);
- best_effort = ((options & DNS_MESSAGEPARSE_BESTEFFORT) != 0);
- seen_problem = false;
-
- section = &msg->sections[sectionid];
-
for (count = 0; count < msg->counts[sectionid]; count++) {
int recstart = source->current;
bool skip_name_search, skip_type_search;
issigzero = false;
istsig = false;
- name = isc_mempool_get(msg->namepool);
- if (name == NULL) {
- return (ISC_R_NOMEMORY);
- }
- free_name = true;
-
- offsets = newoffsets(msg);
- if (offsets == NULL) {
- result = ISC_R_NOMEMORY;
+ name = NULL;
+ result = dns_message_gettempname(msg, &name);
+ if (result != ISC_R_SUCCESS) {
goto cleanup;
}
- dns_name_init(name, *offsets);
+ name->offsets = (unsigned char *)newoffsets(msg);
+ free_name = true;
/*
* Parse the name out of this packet.
* If it is a new name, append to the section.
*/
if (result == ISC_R_SUCCESS) {
- isc_mempool_put(msg->namepool, name);
+ dns_message_puttempname(msg, &name);
name = name2;
} else {
ISC_LIST_APPEND(*section, name, link);
(msg->opt->ttl & DNS_MESSAGE_EDNSRCODE_MASK) >>
20);
msg->rcode |= ercode;
- isc_mempool_put(msg->namepool, name);
+ dns_message_puttempname(msg, &name);
free_name = false;
} else if (issigzero) {
msg->sig0 = rdataset;
if (seen_problem) {
if (free_name) {
- isc_mempool_put(msg->namepool, name);
+ dns_message_puttempname(msg, &name);
}
if (free_rdataset) {
isc_mempool_put(msg->rdspool, rdataset);
cleanup:
if (free_name) {
- isc_mempool_put(msg->namepool, name);
+ dns_message_puttempname(msg, &name);
}
if (free_rdataset) {
isc_mempool_put(msg->rdspool, rdataset);
isc_result_t
dns_message_gettempname(dns_message_t *msg, dns_name_t **item) {
- REQUIRE(DNS_MESSAGE_VALID(msg));
- REQUIRE(item != NULL && *item == NULL);
-
- *item = isc_mempool_get(msg->namepool);
- if (*item == NULL) {
- return (ISC_R_NOMEMORY);
- }
- dns_name_init(*item, NULL);
+ dns_fixedname_t *fn = NULL;
- return (ISC_R_SUCCESS);
-}
-
-isc_result_t
-dns_message_gettempoffsets(dns_message_t *msg, dns_offsets_t **item) {
REQUIRE(DNS_MESSAGE_VALID(msg));
REQUIRE(item != NULL && *item == NULL);
- *item = newoffsets(msg);
- if (*item == NULL) {
+ fn = isc_mempool_get(msg->namepool);
+ if (fn == NULL) {
return (ISC_R_NOMEMORY);
}
+ *item = dns_fixedname_initname(fn);
return (ISC_R_SUCCESS);
}
}
dns_rdataset_init(*item);
-
return (ISC_R_SUCCESS);
}
void
dns_message_puttempname(dns_message_t *msg, dns_name_t **itemp) {
- dns_name_t *item;
+ dns_name_t *item = NULL;
REQUIRE(DNS_MESSAGE_VALID(msg));
REQUIRE(itemp != NULL && *itemp != NULL);
+
item = *itemp;
*itemp = NULL;
+
REQUIRE(!ISC_LINK_LINKED(item, link));
REQUIRE(ISC_LIST_HEAD(item->list) == NULL);
+ /*
+ * we need to check this in case dns_name_dup() was used.
+ */
if (dns_name_dynamic(item)) {
dns_name_free(item, msg->mctx);
}
+
+ /*
+ * 'name' is the first field in dns_fixedname_t, so putting
+ * back the address of name is the same as putting back
+ * the fixedname.
+ */
isc_mempool_put(msg->namepool, item);
}
}
for (; ge != NULL; ge = ge->next) {
- isc_buffer_t *buffer = NULL;
dns_name_t *name = NULL;
dns_rdataset_t *rdataset_a = NULL;
dns_rdataset_t *sigrdataset_a = NULL;
dns_rdataset_t *sigrdataset_aaaa = NULL;
dns_name_t *gluename = dns_fixedname_name(&ge->fixedname);
- isc_buffer_allocate(msg->mctx, &buffer, 512);
-
result = dns_message_gettempname(msg, &name);
if (ISC_UNLIKELY(result != ISC_R_SUCCESS)) {
- isc_buffer_free(&buffer);
goto no_glue;
}
- dns_name_copy(gluename, name, buffer);
- dns_message_takebuffer(msg, &buffer);
+ dns_name_copynf(gluename, name);
if (dns_rdataset_isassociated(&ge->rdataset_a)) {
result = dns_message_gettemprdataset(msg, &rdataset_a);
/*
* Set up question.
*/
- dns_name_init(qname, NULL);
dns_name_clone(&fctx->name, qname);
dns_rdataset_makequestion(qrdataset, res->rdclass, fctx->type);
ISC_LIST_APPEND(qname->list, qrdataset, link);
dns_message_takebuffer(msg, &tmprdatabuf);
RETERR(dns_message_gettempname(msg, &newname));
- dns_name_init(newname, NULL);
- dns_name_dup(name, msg->mctx, newname);
+ dns_name_clone(name, newname);
RETERR(dns_message_gettemprdatalist(msg, &newlist));
newlist->rdclass = newrdata->rdclass;
dns_rdataset_t *question = NULL, *tkeyset = NULL;
dns_rdatalist_t *tkeylist = NULL;
dns_rdata_t *rdata = NULL;
- isc_buffer_t *dynbuf = NULL, *anamebuf = NULL, *qnamebuf = NULL;
+ isc_buffer_t *dynbuf = NULL;
isc_result_t result;
unsigned int len;
len = 16 + tkey->algorithm.length + tkey->keylen + tkey->otherlen;
isc_buffer_allocate(msg->mctx, &dynbuf, len);
- isc_buffer_allocate(msg->mctx, &anamebuf, name->length);
- isc_buffer_allocate(msg->mctx, &qnamebuf, name->length);
RETERR(dns_message_gettemprdata(msg, &rdata));
RETERR(dns_rdata_fromstruct(rdata, dns_rdataclass_any,
RETERR(dns_message_gettemprdataset(msg, &tkeyset));
RETERR(dns_rdatalist_tordataset(tkeylist, tkeyset));
- dns_name_init(qname, NULL);
- RETERR(dns_name_copy(name, qname, qnamebuf));
-
- dns_name_init(aname, NULL);
- RETERR(dns_name_copy(name, aname, anamebuf));
+ dns_name_copynf(name, qname);
+ dns_name_copynf(name, aname);
ISC_LIST_APPEND(qname->list, question, link);
ISC_LIST_APPEND(aname->list, tkeyset, link);
dns_message_addname(msg, qname, DNS_SECTION_QUESTION);
- dns_message_takebuffer(msg, &qnamebuf);
/*
* Windows 2000 needs this in the answer section, not the additional
} else {
dns_message_addname(msg, aname, DNS_SECTION_ADDITIONAL);
}
- dns_message_takebuffer(msg, &anamebuf);
return (ISC_R_SUCCESS);
if (dynbuf != NULL) {
isc_buffer_free(&dynbuf);
}
- if (qnamebuf != NULL) {
- isc_buffer_free(&qnamebuf);
- }
- if (anamebuf != NULL) {
- isc_buffer_free(&anamebuf);
- }
return (result);
}
unsigned char data[128];
isc_buffer_t databuf, sigbuf;
isc_buffer_t *dynbuf = NULL;
- dns_name_t *owner;
+ dns_name_t *owner = NULL;
dns_rdata_t *rdata = NULL;
dns_rdatalist_t *datalist = NULL;
dns_rdataset_t *dataset = NULL;
tsig.signature = NULL;
}
- owner = NULL;
ret = dns_message_gettempname(msg, &owner);
if (ret != ISC_R_SUCCESS) {
goto cleanup_rdata;
}
- dns_name_init(owner, NULL);
- dns_name_dup(&key->name, msg->mctx, owner);
+ dns_name_clone(&key->name, owner);
- datalist = NULL;
ret = dns_message_gettemprdatalist(msg, &datalist);
if (ret != ISC_R_SUCCESS) {
goto cleanup_owner;
}
- dataset = NULL;
+
ret = dns_message_gettemprdataset(msg, &dataset);
if (ret != ISC_R_SUCCESS) {
goto cleanup_rdatalist;
dns_message_getsig0
dns_message_getsig0key
dns_message_gettempname
-dns_message_gettempoffsets
dns_message_gettemprdata
dns_message_gettemprdatalist
dns_message_gettemprdataset
CHECK(dns_rdatalist_tordataset(rdl, rds));
CHECK(dns_message_gettempname(msg, &name));
- dns_name_init(name, NULL);
dns_name_clone(&tuple->name, name);
ISC_LIST_APPEND(name->list, rds, link);
/* Create a name for the question section. */
CHECK(dns_message_gettempname(msg, &qname));
- dns_name_init(qname, NULL);
dns_name_clone(&xfr->name, qname);
/* Formulate the question and attach it to the question name. */
/*
* Make question.
*/
- dns_name_init(qname, NULL);
dns_name_clone(name, qname);
dns_rdataset_makequestion(qrdataset, zone->rdclass, rdtype);
ISC_LIST_APPEND(qname->list, qrdataset, link);
/*
* Make question.
*/
- dns_name_init(tempname, NULL);
dns_name_clone(&zone->origin, tempname);
dns_rdataset_makequestion(temprdataset, zone->rdclass,
dns_rdatatype_soa);
dns_db_attach(zone->db, &zonedb);
ZONEDB_UNLOCK(&zone->dblock, isc_rwlocktype_read);
- dns_name_init(tempname, NULL);
dns_name_clone(&zone->origin, tempname);
dns_db_currentversion(zonedb, &version);
result = dns_db_findnode(zonedb, tempname, false, &node);
isc_result_t
ns_client_newnamebuf(ns_client_t *client) {
- isc_buffer_t *dbuf;
+ isc_buffer_t *dbuf = NULL;
CTRACE("ns_client_newnamebuf");
- dbuf = NULL;
isc_buffer_allocate(client->mctx, &dbuf, 1024);
ISC_LIST_APPEND(client->query.namebufs, dbuf, link);
dns_name_t *
ns_client_newname(ns_client_t *client, isc_buffer_t *dbuf, isc_buffer_t *nbuf) {
- dns_name_t *name;
+ dns_name_t *name = NULL;
isc_region_t r;
isc_result_t result;
CTRACE("ns_client_newname");
- name = NULL;
result = dns_message_gettempname(client->message, &name);
if (result != ISC_R_SUCCESS) {
CTRACE("ns_client_newname: "
}
isc_buffer_availableregion(dbuf, &r);
isc_buffer_init(nbuf, r.base, r.length);
- dns_name_init(name, NULL);
+ dns_name_setbuffer(name, NULL);
dns_name_setbuffer(name, nbuf);
client->query.attributes |= NS_QUERYATTR_NAMEBUFUSED;
isc_buffer_t *
ns_client_getnamebuf(ns_client_t *client) {
isc_buffer_t *dbuf;
- isc_result_t result;
isc_region_t r;
CTRACE("ns_client_getnamebuf");
* a new one if necessary.
*/
if (ISC_LIST_EMPTY(client->query.namebufs)) {
- result = ns_client_newnamebuf(client);
- if (result != ISC_R_SUCCESS) {
- CTRACE("ns_client_getnamebuf: "
- "ns_client_newnamebuf failed: done");
- return (NULL);
- }
+ ns_client_newnamebuf(client);
}
dbuf = ISC_LIST_TAIL(client->query.namebufs);
INSIST(dbuf != NULL);
isc_buffer_availableregion(dbuf, &r);
if (r.length < DNS_NAME_MAXWIRE) {
- result = ns_client_newnamebuf(client);
- if (result != ISC_R_SUCCESS) {
- CTRACE("ns_client_getnamebuf: "
- "ns_client_newnamebuf failed: done");
- return (NULL);
- }
+ ns_client_newnamebuf(client);
dbuf = ISC_LIST_TAIL(client->query.namebufs);
isc_buffer_availableregion(dbuf, &r);
INSIST(r.length >= 255);
void
ns_client_releasename(ns_client_t *client, dns_name_t **namep) {
- dns_name_t *name = *namep;
-
/*%
* 'name' is no longer needed. Return it to our pool of temporary
* names. If it is using a name buffer, relinquish its exclusive
*/
CTRACE("ns_client_releasename");
- if (dns_name_hasbuffer(name)) {
- INSIST((client->query.attributes & NS_QUERYATTR_NAMEBUFUSED) !=
- 0);
- client->query.attributes &= ~NS_QUERYATTR_NAMEBUFUSED;
- }
+ client->query.attributes &= ~NS_QUERYATTR_NAMEBUFUSED;
dns_message_puttempname(client->message, namep);
CTRACE("ns_client_releasename: done");
}
isc_result_t
ns_client_newdbversion(ns_client_t *client, unsigned int n) {
unsigned int i;
- ns_dbversion_t *dbversion;
+ ns_dbversion_t *dbversion = NULL;
for (i = 0; i < n; i++) {
dbversion = isc_mem_get(client->mctx, sizeof(*dbversion));
- {
- dbversion->db = NULL;
- dbversion->version = NULL;
- ISC_LIST_INITANDAPPEND(client->query.freeversions,
- dbversion, link);
- }
+ *dbversion = (ns_dbversion_t){ 0 };
+ ISC_LIST_INITANDAPPEND(client->query.freeversions, dbversion,
+ link);
}
return (ISC_R_SUCCESS);
static inline ns_dbversion_t *
client_getdbversion(ns_client_t *client) {
- isc_result_t result;
- ns_dbversion_t *dbversion;
+ ns_dbversion_t *dbversion = NULL;
if (ISC_LIST_EMPTY(client->query.freeversions)) {
- result = ns_client_newdbversion(client, 1);
- if (result != ISC_R_SUCCESS) {
- return (NULL);
- }
+ ns_client_newdbversion(client, 1);
}
dbversion = ISC_LIST_HEAD(client->query.freeversions);
INSIST(dbversion != NULL);
isc_result_t
ns_query_init(ns_client_t *client) {
- isc_result_t result;
+ isc_result_t result = ISC_R_SUCCESS;
REQUIRE(NS_CLIENT_VALID(client));
client->query.redirect.fname =
dns_fixedname_initname(&client->query.redirect.fixed);
query_reset(client, false);
- result = ns_client_newdbversion(client, 3);
- if (result != ISC_R_SUCCESS) {
- isc_mutex_destroy(&client->query.fetchlock);
- return (result);
- }
- result = ns_client_newnamebuf(client);
- if (result != ISC_R_SUCCESS) {
- query_freefreeversions(client, true);
- isc_mutex_destroy(&client->query.fetchlock);
- }
+ ns_client_newdbversion(client, 3);
+ ns_client_newnamebuf(client);
return (result);
}
RUNTIME_CHECK(result == ISC_R_SUCCESS);
dns_rdata_reset(&rdata);
- dns_name_init(tname, NULL);
- dns_name_dup(&cname.cname, qctx->client->mctx, tname);
+ dns_name_clone(&cname.cname, tname);
dns_rdata_freestruct(&cname);
ns_client_qnamereplace(qctx->client, tname);
static isc_result_t
query_cname(query_ctx_t *qctx) {
isc_result_t result = ISC_R_UNSET;
- dns_name_t *tname;
- dns_rdataset_t *trdataset;
+ dns_name_t *tname = NULL;
+ dns_rdataset_t *trdataset = NULL;
dns_rdataset_t **sigrdatasetp = NULL;
dns_rdata_t rdata = DNS_RDATA_INIT;
dns_rdata_cname_t cname;
* Reset qname to be the target name of the CNAME and restart
* the query.
*/
- tname = NULL;
result = dns_message_gettempname(qctx->client->message, &tname);
if (result != ISC_R_SUCCESS) {
return (ns_query_done(qctx));
RUNTIME_CHECK(result == ISC_R_SUCCESS);
dns_rdata_reset(&rdata);
- dns_name_init(tname, NULL);
- dns_name_dup(&cname.cname, qctx->client->mctx, tname);
+ dns_name_clone(&cname.cname, tname);
dns_rdata_freestruct(&cname);
ns_client_qnamereplace(qctx->client, tname);
if (result != ISC_R_SUCCESS) {
return (result);
}
- dns_name_dup(client->query.qname, client->mctx, aname);
+ dns_name_clone(client->query.qname, aname);
result = dns_message_gettemprdatalist(client->message, &rdatalist);
if (result != ISC_R_SUCCESS) {
if (result != ISC_R_SUCCESS) {
return (result);
}
- dns_name_init(name, NULL);
dns_name_clone(dns_db_origin(qctx->db), name);
rdataset = ns_client_newrdataset(client);
if (rdataset == NULL) {
"failed: done");
return (result);
}
- dns_name_init(name, NULL);
dns_name_clone(dns_db_origin(qctx->db), name);
rdataset = ns_client_newrdataset(client);
if (rdataset == NULL) {
if (result != ISC_R_SUCCESS) {
goto failure;
}
- dns_name_init(qname, NULL);
isc_buffer_availableregion(&xfr->buf, &r);
INSIST(r.length >= xfr->qname->length);
r.length = xfr->qname->length;
if (result != ISC_R_SUCCESS) {
goto failure;
}
- dns_name_init(msgname, NULL);
isc_buffer_availableregion(&xfr->buf, &r);
INSIST(r.length >= name->length);
r.length = name->length;