+1914. [bug] Strings returned from cfg_obj_asstring() should be
+ treated as read-only. The prototype for
+ cfg_obj_asstring() has been updated to reflect this.
+ [RT #15256]
+
1913. [func] Automatic empty zone creation for D.F.IP6.ARPA and
friends. Note: RFC 1918 zones are not yet covered by
this but are likely to be in a future release.
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: named-checkconf.c,v 1.36 2005/08/22 00:58:18 marka Exp $ */
+/* $Id: named-checkconf.c,v 1.37 2005/08/23 02:36:05 marka Exp $ */
/*! \file */
static isc_result_t
directory_callback(const char *clausename, cfg_obj_t *obj, void *arg) {
isc_result_t result;
- char *directory;
+ const char *directory;
REQUIRE(strcasecmp("directory", clausename) == 0);
fmtobj = NULL;
result = config_get(maps, "masterfile-format", &fmtobj);
if (result == ISC_R_SUCCESS) {
- char *masterformatstr = cfg_obj_asstring(fmtobj);
+ const char *masterformatstr = cfg_obj_asstring(fmtobj);
if (strcasecmp(masterformatstr, "text") == 0)
masterformat = dns_masterformat_text;
else if (strcasecmp(masterformatstr, "raw") == 0)
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: config.c,v 1.58 2005/06/27 00:15:41 marka Exp $ */
+/* $Id: config.c,v 1.59 2005/08/23 02:36:06 marka Exp $ */
/*! \file */
isc_result_t
ns_config_getclass(cfg_obj_t *classobj, dns_rdataclass_t defclass,
dns_rdataclass_t *classp) {
- char *str;
isc_textregion_t r;
isc_result_t result;
*classp = defclass;
return (ISC_R_SUCCESS);
}
- str = cfg_obj_asstring(classobj);
- r.base = str;
- r.length = strlen(str);
+ DE_CONST(cfg_obj_asstring(classobj), r.base);
+ r.length = strlen(r.base);
result = dns_rdataclass_fromtext(classp, &r);
if (result != ISC_R_SUCCESS)
cfg_obj_log(classobj, ns_g_lctx, ISC_LOG_ERROR,
- "unknown class '%s'", str);
+ "unknown class '%s'", r.base);
return (result);
}
isc_result_t
ns_config_gettype(cfg_obj_t *typeobj, dns_rdatatype_t deftype,
dns_rdatatype_t *typep) {
- char *str;
isc_textregion_t r;
isc_result_t result;
*typep = deftype;
return (ISC_R_SUCCESS);
}
- str = cfg_obj_asstring(typeobj);
- r.base = str;
- r.length = strlen(str);
+ DE_CONST(cfg_obj_asstring(typeobj), r.base);
+ r.length = strlen(r.base);
result = dns_rdatatype_fromtext(typep, &r);
if (result != ISC_R_SUCCESS)
cfg_obj_log(typeobj, ns_g_lctx, ISC_LOG_ERROR,
- "unknown type '%s'", str);
+ "unknown type '%s'", r.base);
return (result);
}
dns_zonetype_t
ns_config_getzonetype(cfg_obj_t *zonetypeobj) {
dns_zonetype_t ztype = dns_zone_none;
- char *str;
+ const char *str;
str = cfg_obj_asstring(zonetypeobj);
if (strcasecmp(str, "master") == 0)
}
static isc_result_t
-get_masters_def(cfg_obj_t *cctx, char *name, cfg_obj_t **ret) {
+get_masters_def(cfg_obj_t *cctx, const char *name, cfg_obj_t **ret) {
isc_result_t result;
cfg_obj_t *masters = NULL;
cfg_listelt_t *elt;
dns_fixedname_t fname;
isc_sockaddr_t *addrs = NULL;
dns_name_t **keys = NULL;
- char **lists = NULL;
+ const char **lists = NULL;
struct {
cfg_listelt_t *element;
in_port_t port;
{
cfg_obj_t *addr;
cfg_obj_t *key;
- char *keystr;
+ const char *keystr;
isc_buffer_t b;
addr = cfg_tuple_get(cfg_listelt_value(element),
key = cfg_tuple_get(cfg_listelt_value(element), "key");
if (!cfg_obj_issockaddr(addr)) {
- char *listname = cfg_obj_asstring(addr);
+ const char *listname = cfg_obj_asstring(addr);
isc_result_t tresult;
/* Grow lists? */
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: controlconf.c,v 1.44 2005/04/27 04:55:50 sra Exp $ */
+/* $Id: controlconf.c,v 1.45 2005/08/23 02:36:06 marka Exp $ */
/*! \file */
} else {
cfg_obj_t *algobj = NULL;
cfg_obj_t *secretobj = NULL;
- char *algstr = NULL;
- char *secretstr = NULL;
+ const char *algstr = NULL;
+ const char *secretstr = NULL;
(void)cfg_map_get(keydef, "algorithm", &algobj);
(void)cfg_map_get(keydef, "secret", &secretobj);
cfg_obj_t *key = NULL;
cfg_obj_t *algobj = NULL;
cfg_obj_t *secretobj = NULL;
- char *algstr = NULL;
- char *secretstr = NULL;
+ const char *algstr = NULL;
+ const char *secretstr = NULL;
controlkey_t *keyid = NULL;
char secret[1024];
isc_buffer_t b;
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: logconf.c,v 1.37 2005/04/29 00:22:27 marka Exp $ */
+/* $Id: logconf.c,v 1.38 2005/08/23 02:36:06 marka Exp $ */
/*! \file */
element = cfg_list_next(element))
{
cfg_obj_t *channel = cfg_listelt_value(element);
- char *channelname = cfg_obj_asstring(channel);
+ const char *channelname = cfg_obj_asstring(channel);
result = isc_log_usechannel(lctx, channelname, category,
module);
type = ISC_LOG_TOSYSLOG;
if (cfg_obj_isstring(syslogobj)) {
- char *facilitystr = cfg_obj_asstring(syslogobj);
+ const char *facilitystr = cfg_obj_asstring(syslogobj);
(void)isc_syslog_facilityfromstring(facilitystr,
&facility);
}
level = ISC_LOG_INFO;
if (cfg_map_get(channel, "severity", &severity) == ISC_R_SUCCESS) {
if (cfg_obj_isstring(severity)) {
- char *str = cfg_obj_asstring(severity);
+ const char *str = cfg_obj_asstring(severity);
if (strcasecmp(str, "critical") == 0)
level = ISC_LOG_CRITICAL;
else if (strcasecmp(str, "error") == 0)
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: lwresd.c,v 1.49 2005/07/12 01:00:13 marka Exp $ */
+/* $Id: lwresd.c,v 1.50 2005/08/23 02:36:07 marka Exp $ */
/*! \file
* \brief
element = cfg_list_next(element))
{
cfg_obj_t *search;
- char *searchstr;
+ const char *searchstr;
isc_buffer_t namebuf;
dns_fixedname_t fname;
dns_name_t *name;
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: server.c,v 1.448 2005/08/18 00:57:27 marka Exp $ */
+/* $Id: server.c,v 1.449 2005/08/23 02:36:07 marka Exp $ */
/*! \file */
dns_rdataclass_t viewclass;
dns_rdata_dnskey_t keystruct;
isc_uint32_t flags, proto, alg;
- char *keystr, *keynamestr;
+ const char *keystr, *keynamestr;
unsigned char keydata[4096];
isc_buffer_t keydatabuf;
unsigned char rrdata[4096];
isc_netaddr_t na;
dns_peer_t *peer;
cfg_obj_t *obj;
- char *str;
+ const char *str;
isc_result_t result;
unsigned int prefixlen;
isc_textregion_t r;
dns_secalg_t alg;
- r.base = cfg_obj_asstring(cfg_listelt_value(element));
+ DE_CONST(cfg_obj_asstring(cfg_listelt_value(element)), r.base);
r.length = strlen(r.base);
result = dns_secalg_fromtext(&alg, &r);
dns_fixedname_t fixed;
dns_name_t *name;
isc_buffer_t b;
- char *str;
+ const char *str;
cfg_obj_t *exclude;
dns_fixedname_init(&fixed);
dns_fixedname_t fixed;
dns_name_t *name;
isc_buffer_t buffer;
- char *str;
+ const char *str;
char server[DNS_NAME_FORMATSIZE + 1];
char contact[DNS_NAME_FORMATSIZE + 1];
isc_boolean_t logit;
if (!cfg_obj_issockaddr(alternate)) {
dns_fixedname_t fixed;
dns_name_t *name;
- char *str = cfg_obj_asstring(cfg_tuple_get(alternate,
- "name"));
+ const char *str = cfg_obj_asstring(cfg_tuple_get(
+ alternate, "name"));
isc_buffer_t buffer;
in_port_t myport = port;
if (forwardtype == NULL)
fwdpolicy = dns_fwdpolicy_first;
else {
- char *forwardstr = cfg_obj_asstring(forwardtype);
+ const char *forwardstr = cfg_obj_asstring(forwardtype);
if (strcasecmp(forwardstr, "first") == 0)
fwdpolicy = dns_fwdpolicy_first;
else if (strcasecmp(forwardstr, "only") == 0)
goto cleanup;
}
if (dns_name_equal(origin, dns_rootname)) {
- char *hintsfile = cfg_obj_asstring(fileobj);
+ const char *hintsfile = cfg_obj_asstring(fileobj);
result = configure_hints(view, hintsfile);
if (result != ISC_R_SUCCESS) {
static isc_result_t
directory_callback(const char *clausename, cfg_obj_t *obj, void *arg) {
isc_result_t result;
- char *directory;
+ const char *directory;
REQUIRE(strcasecmp("directory", clausename) == 0);
isc_resource_t resourceid, isc_resourcevalue_t defaultvalue)
{
cfg_obj_t *obj = NULL;
- char *resource;
+ const char *resource;
isc_resourcevalue_t value;
isc_result_t result;
element = cfg_list_next(element))
{
cfg_obj_t *catobj;
- char *str;
+ const char *str;
obj = cfg_listelt_value(element);
catobj = cfg_tuple_get(obj, "name");
"creating heartbeat timer");
CHECKFATAL(isc_timer_create(ns_g_timermgr, isc_timertype_inactive,
- NULL, NULL, server->task,
- heartbeat_timer_tick,
+ NULL, NULL, server->task, pps_timer_tick,
server, &server->pps_timer),
"creating pps timer");
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: tkeyconf.c,v 1.23 2005/04/29 00:22:29 marka Exp $ */
+/* $Id: tkeyconf.c,v 1.24 2005/08/23 02:36:07 marka Exp $ */
/*! \file */
{
isc_result_t result;
dns_tkeyctx_t *tctx = NULL;
- char *s;
+ const char *s;
isc_uint32_t n;
dns_fixedname_t fname;
dns_name_t *name;
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: tsigconf.c,v 1.24 2005/04/29 00:22:29 marka Exp $ */
+/* $Id: tsigconf.c,v 1.25 2005/08/23 02:36:07 marka Exp $ */
/*! \file */
add_initial_keys(cfg_obj_t *list, dns_tsig_keyring_t *ring, isc_mem_t *mctx) {
cfg_listelt_t *element;
cfg_obj_t *key = NULL;
- char *keyid = NULL;
+ const char *keyid = NULL;
unsigned char *secret = NULL;
int secretalloc = 0;
int secretlen = 0;
cfg_obj_t *secretobj = NULL;
dns_name_t keyname;
dns_name_t *alg;
- char *algstr;
+ const char *algstr;
char keynamedata[1024];
isc_buffer_t keynamesrc, keynamebuf;
- char *secretstr;
+ const char *secretstr;
isc_buffer_t secretbuf;
key = cfg_listelt_value(element);
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: zoneconf.c,v 1.122 2005/06/20 01:03:49 marka Exp $ */
+/* $Id: zoneconf.c,v 1.123 2005/08/23 02:36:08 marka Exp $ */
/*% */
cfg_obj_t *matchtype = cfg_tuple_get(stmt, "matchtype");
cfg_obj_t *dname = cfg_tuple_get(stmt, "name");
cfg_obj_t *typelist = cfg_tuple_get(stmt, "types");
- char *str;
+ const char *str;
isc_boolean_t grant = ISC_FALSE;
unsigned int mtype = DNS_SSUMATCHTYPE_NAME;
dns_fixedname_t fname, fident;
typeobj = cfg_listelt_value(element2);
str = cfg_obj_asstring(typeobj);
- r.base = str;
+ DE_CONST(str, r.base);
r.length = strlen(str);
result = dns_rdatatype_fromtext(&types[i++], &r);
cfg_aclconfctx_t *ac, dns_zone_t *zone)
{
isc_result_t result;
- char *zname;
+ const char *zname;
dns_rdataclass_t zclass;
dns_rdataclass_t vclass;
cfg_obj_t *maps[5];
obj = NULL;
result = cfg_map_get(zoptions, "database", &obj);
if (result == ISC_R_SUCCESS)
- cpval = cfg_obj_asstring(obj);
+ cpval = isc_mem_strdup(mctx, cfg_obj_asstring(obj));
else
cpval = default_dbtype;
- RETERR(strtoargv(mctx, cpval, &dbargc, &dbargv));
+
+ if (cpval == NULL)
+ return(ISC_R_NOMEMORY);
+
+ result = strtoargv(mctx, cpval, &dbargc, &dbargv);
+ if (result != ISC_R_SUCCESS && cpval != default_dbtype) {
+ isc_mem_free(mctx, cpval);
+ return (result);
+ }
+
/*
* ANSI C is strange here. There is no logical reason why (char **)
* cannot be promoted automatically to (const char * const *) by the
* compiler w/o generating a warning.
*/
- RETERR(dns_zone_setdbtype(zone, dbargc, (const char * const *)dbargv));
+ result = dns_zone_setdbtype(zone, dbargc, (const char * const *)dbargv);
isc_mem_put(mctx, dbargv, dbargc * sizeof(*dbargv));
+ if (cpval != default_dbtype)
+ isc_mem_free(mctx, cpval);
+ if (result != ISC_R_SUCCESS)
+ return (result);
obj = NULL;
result = cfg_map_get(zoptions, "file", &obj);
obj = NULL;
result= ns_config_get(maps, "masterfile-format", &obj);
if (result == ISC_R_SUCCESS) {
- char *masterformatstr = cfg_obj_asstring(obj);
+ const char *masterformatstr = cfg_obj_asstring(obj);
if (strcasecmp(masterformatstr, "text") == 0)
masterformat = dns_masterformat_text;
else
dialup = dns_dialuptype_no;
} else {
- char *dialupstr = cfg_obj_asstring(obj);
+ const char *dialupstr = cfg_obj_asstring(obj);
if (strcasecmp(dialupstr, "notify") == 0)
dialup = dns_dialuptype_notify;
else if (strcasecmp(dialupstr, "notify-passive") == 0)
else
notifytype = dns_notifytype_no;
} else {
- char *notifystr = cfg_obj_asstring(obj);
+ const char *notifystr = cfg_obj_asstring(obj);
if (strcasecmp(notifystr, "explicit") == 0)
notifytype = dns_notifytype_explicit;
else if (strcasecmp(notifystr, "master-only") == 0)
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: named.conf,v 1.4 2004/03/05 04:59:23 marka Exp $ */
+/* $Id: named.conf,v 1.5 2005/08/23 02:36:08 marka Exp $ */
controls { /* empty */ };
listen-on-v6 { none; };
notify yes;
max-cache-size 10000;
+ disable-empty-zone 127.IN-ADDR.ARPA;
};
zone "." {
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: check.c,v 1.62 2005/08/18 00:57:28 marka Exp $ */
+/* $Id: check.c,v 1.63 2005/08/23 02:36:08 marka Exp $ */
/*! \file */
cfg_obj_t *alternates = NULL;
cfg_obj_t *value;
cfg_obj_t *obj;
- char *str;
+ const char *str;
dns_fixedname_t fixed;
dns_name_t *name;
isc_buffer_t buffer;
dns_secalg_t alg;
isc_result_t tresult;
- r.base = cfg_obj_asstring(cfg_listelt_value(element));
+ DE_CONST(cfg_obj_asstring(cfg_listelt_value(element)), r.base);
r.length = strlen(r.base);
tresult = dns_secalg_fromtext(&alg, &r);
}
if (tresult != ISC_R_SUCCESS) {
cfg_obj_log(cfg_listelt_value(element), logctx,
- ISC_LOG_ERROR, "invalid algorithm");
+ ISC_LOG_ERROR, "invalid algorithm '%s'",
+ r.base);
result = tresult;
}
}
if (!cfg_obj_isvoid(obj)) {
cfg_listelt_t *element;
cfg_obj_t *exclude;
- char *str;
+ const char *str;
dns_fixedname_t fixed;
dns_name_t *name;
isc_buffer_t b;
}
static isc_result_t
-get_masters_def(cfg_obj_t *cctx, char *name, cfg_obj_t **ret) {
+get_masters_def(cfg_obj_t *cctx, const char *name, cfg_obj_t **ret) {
isc_result_t result;
cfg_obj_t *masters = NULL;
cfg_listelt_t *elt;
element != NULL;
element = cfg_list_next(element))
{
- char *listname;
+ const char *listname;
cfg_obj_t *addr;
cfg_obj_t *key;
cfg_listelt_t *element;
cfg_listelt_t *element2;
dns_fixedname_t fixed;
- char *str;
+ const char *str;
isc_buffer_t b;
for (element = cfg_list_first(policy);
dns_rdatatype_t type;
typeobj = cfg_listelt_value(element2);
- str = cfg_obj_asstring(typeobj);
- r.base = str;
- r.length = strlen(str);
+ DE_CONST(cfg_obj_asstring(typeobj), r.base);
+ r.length = strlen(r.base);
tresult = dns_rdatatype_fromtext(&type, &r);
if (tresult != ISC_R_SUCCESS) {
cfg_obj_log(typeobj, logctx, ISC_LOG_ERROR,
- "'%s' is not a valid type", str);
+ "'%s' is not a valid type", r.base);
result = tresult;
}
}
cfg_obj_t *dialup = NULL;
(void)cfg_map_get(zoptions, "dialup", &dialup);
if (dialup != NULL && cfg_obj_isstring(dialup)) {
- char *str = cfg_obj_asstring(dialup);
+ const char *str = cfg_obj_asstring(dialup);
for (i = 0;
i < sizeof(dialups) / sizeof(dialups[0]);
i++)
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: cache.c,v 1.62 2005/08/15 01:21:05 marka Exp $ */
+/* $Id: cache.c,v 1.63 2005/08/23 02:36:09 marka Exp $ */
/*! \file */
}
isc_result_t
-dns_cache_setfilename(dns_cache_t *cache, char *filename) {
+dns_cache_setfilename(dns_cache_t *cache, const char *filename) {
char *newname;
REQUIRE(VALID_CACHE(cache));
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: cache.h,v 1.21 2005/04/29 00:22:54 marka Exp $ */
+/* $Id: cache.h,v 1.22 2005/08/23 02:36:09 marka Exp $ */
#ifndef DNS_CACHE_H
#define DNS_CACHE_H 1
isc_result_t
-dns_cache_setfilename(dns_cache_t *cahce, char *filename);
+dns_cache_setfilename(dns_cache_t *cache, const char *filename);
/*%<
* If 'filename' is non-NULL, make the cache persistent.
* The cache's data will be stored in the given file.
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: aclconf.c,v 1.4 2005/03/16 03:34:45 marka Exp $ */
+/* $Id: aclconf.c,v 1.5 2005/08/23 02:36:10 marka Exp $ */
#include <config.h>
* Find the definition of the named acl whose name is "name".
*/
static isc_result_t
-get_acl_def(cfg_obj_t *cctx, char *name, cfg_obj_t **ret) {
+get_acl_def(cfg_obj_t *cctx, const char *name, cfg_obj_t **ret) {
isc_result_t result;
cfg_obj_t *acls = NULL;
cfg_listelt_t *elt;
cfg_obj_t *cacl = NULL;
dns_acl_t *dacl;
dns_acl_t loop;
- char *aclname = cfg_obj_asstring(nameobj);
+ const char *aclname = cfg_obj_asstring(nameobj);
/* Look for an already-converted version. */
for (dacl = ISC_LIST_HEAD(ctx->named_acl_cache);
*/
memset(&loop, 0, sizeof(loop));
ISC_LINK_INIT(&loop, nextincache);
- loop.name = aclname;
+ DE_CONST(aclname, loop.name);
loop.magic = LOOP_MAGIC;
ISC_LIST_APPEND(ctx->named_acl_cache, &loop, nextincache);
result = cfg_acl_fromconfig(cacl, cctx, lctx, ctx, mctx, &dacl);
goto cleanup;
} else if (cfg_obj_isstring(ce)) {
/* ACL name */
- char *name = cfg_obj_asstring(ce);
+ const char *name = cfg_obj_asstring(ce);
if (strcasecmp(name, "localhost") == 0) {
de->type = dns_aclelementtype_localhost;
} else if (strcasecmp(name, "localnets") == 0) {
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: cfg.h,v 1.36 2005/04/29 00:24:03 marka Exp $ */
+/* $Id: cfg.h,v 1.37 2005/08/23 02:36:11 marka Exp $ */
#ifndef ISCCFG_CFG_H
#define ISCCFG_CFG_H 1
* Return true iff 'obj' is of string type.
*/
-char *
+const char *
cfg_obj_asstring(cfg_obj_t *obj);
/*%<
* Returns the value of a configuration object of a string type
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: parser.c,v 1.117 2005/04/27 04:57:28 sra Exp $ */
+/* $Id: parser.c,v 1.118 2005/08/23 02:36:10 marka Exp $ */
/*! \file */
return (ISC_TF(obj->type->rep == &cfg_rep_string));
}
-char *
+const char *
cfg_obj_asstring(cfg_obj_t *obj) {
REQUIRE(obj != NULL && obj->type->rep == &cfg_rep_string);
return (obj->value.string.base);