diff --git a/CHANGES b/CHANGES index ae205259e6..54f09a8b3b 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +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. diff --git a/bin/check/named-checkconf.c b/bin/check/named-checkconf.c index 773fcc008e..c77974845b 100644 --- a/bin/check/named-checkconf.c +++ b/bin/check/named-checkconf.c @@ -15,7 +15,7 @@ * 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 */ @@ -68,7 +68,7 @@ usage(void) { 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); @@ -241,7 +241,7 @@ configure_zone(const char *vclass, const char *view, cfg_obj_t *zconfig, 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) diff --git a/bin/named/config.c b/bin/named/config.c index ed10b10a51..36a6c3f101 100644 --- a/bin/named/config.c +++ b/bin/named/config.c @@ -15,7 +15,7 @@ * 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 */ @@ -268,7 +268,6 @@ ns_config_listcount(cfg_obj_t *list) { 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; @@ -276,20 +275,18 @@ ns_config_getclass(cfg_obj_t *classobj, dns_rdataclass_t defclass, *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; @@ -297,20 +294,19 @@ ns_config_gettype(cfg_obj_t *typeobj, dns_rdatatype_t deftype, *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) @@ -392,7 +388,7 @@ ns_config_putiplist(isc_mem_t *mctx, isc_sockaddr_t **addrsp, } 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; @@ -433,7 +429,7 @@ ns_config_getipandkeylist(cfg_obj_t *config, cfg_obj_t *list, isc_mem_t *mctx, 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; @@ -470,7 +466,7 @@ ns_config_getipandkeylist(cfg_obj_t *config, cfg_obj_t *list, isc_mem_t *mctx, { 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), @@ -478,7 +474,7 @@ ns_config_getipandkeylist(cfg_obj_t *config, cfg_obj_t *list, isc_mem_t *mctx, 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? */ diff --git a/bin/named/controlconf.c b/bin/named/controlconf.c index 2c4b2689f4..47c60ab071 100644 --- a/bin/named/controlconf.c +++ b/bin/named/controlconf.c @@ -15,7 +15,7 @@ * 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 */ @@ -747,8 +747,8 @@ register_keys(cfg_obj_t *control, cfg_obj_t *keylist, } 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); @@ -817,8 +817,8 @@ get_rndckey(isc_mem_t *mctx, controlkeylist_t *keyids) { 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; diff --git a/bin/named/logconf.c b/bin/named/logconf.c index cf6ad6ecb7..fb485cfc27 100644 --- a/bin/named/logconf.c +++ b/bin/named/logconf.c @@ -15,7 +15,7 @@ * 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 */ @@ -71,7 +71,7 @@ category_fromconf(cfg_obj_t *ccat, isc_logconfig_t *lctx) { 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); @@ -159,7 +159,7 @@ channel_fromconf(cfg_obj_t *channel, isc_logconfig_t *lctx) { 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); } @@ -195,7 +195,7 @@ channel_fromconf(cfg_obj_t *channel, isc_logconfig_t *lctx) { 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) diff --git a/bin/named/lwresd.c b/bin/named/lwresd.c index 3e9ed5a59d..56feffdaa4 100644 --- a/bin/named/lwresd.c +++ b/bin/named/lwresd.c @@ -15,7 +15,7 @@ * 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 @@ -358,7 +358,7 @@ ns_lwdmanager_create(isc_mem_t *mctx, cfg_obj_t *lwres, 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; diff --git a/bin/named/server.c b/bin/named/server.c index 0abab522b9..1a1674f517 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -15,7 +15,7 @@ * 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 */ @@ -294,7 +294,7 @@ configure_view_dnsseckey(cfg_obj_t *vconfig, cfg_obj_t *key, 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]; @@ -642,7 +642,7 @@ configure_peer(cfg_obj_t *cpeer, isc_mem_t *mctx, dns_peer_t **peerp) { isc_netaddr_t na; dns_peer_t *peer; cfg_obj_t *obj; - char *str; + const char *str; isc_result_t result; unsigned int prefixlen; @@ -755,7 +755,7 @@ disable_algorithms(cfg_obj_t *disabled, dns_resolver_t *resolver) { 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); @@ -1438,7 +1438,7 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig, 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); @@ -1486,7 +1486,7 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig, 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; @@ -1681,8 +1681,8 @@ configure_alternates(cfg_obj_t *config, dns_view_t *view, 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; @@ -1788,7 +1788,7 @@ configure_forward(cfg_obj_t *config, dns_view_t *view, dns_name_t *origin, 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) @@ -1946,7 +1946,7 @@ configure_zone(cfg_obj_t *config, cfg_obj_t *zconfig, cfg_obj_t *vconfig, 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) { @@ -2123,7 +2123,7 @@ configure_server_quota(cfg_obj_t **maps, const char *name, isc_quota_t *quota) 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); @@ -2387,7 +2387,7 @@ set_limit(cfg_obj_t **maps, const char *configname, const char *description, 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; @@ -2969,7 +2969,7 @@ load_configuration(const char *filename, ns_server_t *server, 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"); @@ -3188,8 +3188,7 @@ run_server(isc_task_t *task, isc_event_t *event) { "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"); diff --git a/bin/named/tkeyconf.c b/bin/named/tkeyconf.c index 9fbd88dce6..f7dd5dd247 100644 --- a/bin/named/tkeyconf.c +++ b/bin/named/tkeyconf.c @@ -15,7 +15,7 @@ * 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 */ @@ -49,7 +49,7 @@ ns_tkeyctx_fromconfig(cfg_obj_t *options, isc_mem_t *mctx, isc_entropy_t *ectx, { 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; diff --git a/bin/named/tsigconf.c b/bin/named/tsigconf.c index f80ea7798e..4cc9c36930 100644 --- a/bin/named/tsigconf.c +++ b/bin/named/tsigconf.c @@ -15,7 +15,7 @@ * 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 */ @@ -40,7 +40,7 @@ static isc_result_t 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; @@ -55,10 +55,10 @@ add_initial_keys(cfg_obj_t *list, dns_tsig_keyring_t *ring, isc_mem_t *mctx) { 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); diff --git a/bin/named/zoneconf.c b/bin/named/zoneconf.c index fb02988cdb..2fb4e873f4 100644 --- a/bin/named/zoneconf.c +++ b/bin/named/zoneconf.c @@ -15,7 +15,7 @@ * 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 $ */ /*% */ @@ -126,7 +126,7 @@ configure_zone_ssutable(cfg_obj_t *zconfig, dns_zone_t *zone) { 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; @@ -201,7 +201,7 @@ configure_zone_ssutable(cfg_obj_t *zconfig, dns_zone_t *zone) { 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); @@ -315,7 +315,7 @@ ns_zone_configure(cfg_obj_t *config, cfg_obj_t *vconfig, cfg_obj_t *zconfig, 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]; @@ -380,17 +380,30 @@ ns_zone_configure(cfg_obj_t *config, cfg_obj_t *vconfig, cfg_obj_t *zconfig, 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); @@ -401,7 +414,7 @@ ns_zone_configure(cfg_obj_t *config, cfg_obj_t *vconfig, cfg_obj_t *zconfig, 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; @@ -439,7 +452,7 @@ ns_zone_configure(cfg_obj_t *config, cfg_obj_t *vconfig, cfg_obj_t *zconfig, 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) @@ -473,7 +486,7 @@ ns_zone_configure(cfg_obj_t *config, cfg_obj_t *vconfig, cfg_obj_t *zconfig, 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) diff --git a/bin/tests/system/cacheclean/ns2/named.conf b/bin/tests/system/cacheclean/ns2/named.conf index 3884fb949e..5a56b696a5 100644 --- a/bin/tests/system/cacheclean/ns2/named.conf +++ b/bin/tests/system/cacheclean/ns2/named.conf @@ -15,7 +15,7 @@ * 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 */ }; @@ -29,6 +29,7 @@ options { listen-on-v6 { none; }; notify yes; max-cache-size 10000; + disable-empty-zone 127.IN-ADDR.ARPA; }; zone "." { diff --git a/lib/bind9/check.c b/lib/bind9/check.c index e682f43db5..44b6fe7438 100644 --- a/lib/bind9/check.c +++ b/lib/bind9/check.c @@ -15,7 +15,7 @@ * 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 */ @@ -162,7 +162,7 @@ check_dual_stack(cfg_obj_t *options, isc_log_t *logctx) { 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; @@ -266,7 +266,7 @@ disabled_algorithms(cfg_obj_t *disabled, isc_log_t *logctx) { 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); @@ -276,7 +276,8 @@ disabled_algorithms(cfg_obj_t *disabled, isc_log_t *logctx) { } 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; } } @@ -472,7 +473,7 @@ check_options(cfg_obj_t *options, isc_log_t *logctx, isc_mem_t *mctx) { 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; @@ -666,7 +667,7 @@ check_options(cfg_obj_t *options, isc_log_t *logctx, isc_mem_t *mctx) { } 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; @@ -718,7 +719,7 @@ validate_masters(cfg_obj_t *obj, cfg_obj_t *config, isc_uint32_t *countp, element != NULL; element = cfg_list_next(element)) { - char *listname; + const char *listname; cfg_obj_t *addr; cfg_obj_t *key; @@ -792,7 +793,7 @@ check_update_policy(cfg_obj_t *policy, isc_log_t *logctx) { 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); @@ -845,14 +846,13 @@ check_update_policy(cfg_obj_t *policy, isc_log_t *logctx) { 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; } } @@ -1107,7 +1107,7 @@ check_zoneconf(cfg_obj_t *zconfig, cfg_obj_t *voptions, cfg_obj_t *config, 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++) diff --git a/lib/dns/cache.c b/lib/dns/cache.c index 0d3bd2a6b6..0da82eacd1 100644 --- a/lib/dns/cache.c +++ b/lib/dns/cache.c @@ -15,7 +15,7 @@ * 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 */ @@ -443,7 +443,7 @@ dns_cache_attachdb(dns_cache_t *cache, dns_db_t **dbp) { } 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)); diff --git a/lib/dns/include/dns/cache.h b/lib/dns/include/dns/cache.h index dfb2371f1a..a660c33755 100644 --- a/lib/dns/include/dns/cache.h +++ b/lib/dns/include/dns/cache.h @@ -15,7 +15,7 @@ * 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 @@ -149,7 +149,7 @@ dns_cache_attachdb(dns_cache_t *cache, dns_db_t **dbp); 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. diff --git a/lib/isccfg/aclconf.c b/lib/isccfg/aclconf.c index 3aa4ac6fa1..a93c1181bd 100644 --- a/lib/isccfg/aclconf.c +++ b/lib/isccfg/aclconf.c @@ -15,7 +15,7 @@ * 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 @@ -53,7 +53,7 @@ cfg_aclconfctx_destroy(cfg_aclconfctx_t *ctx) { * 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; @@ -83,7 +83,7 @@ convert_named_acl(cfg_obj_t *nameobj, cfg_obj_t *cctx, 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); @@ -112,7 +112,7 @@ convert_named_acl(cfg_obj_t *nameobj, cfg_obj_t *cctx, */ 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); @@ -218,7 +218,7 @@ cfg_acl_fromconfig(cfg_obj_t *caml, 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) { diff --git a/lib/isccfg/include/isccfg/cfg.h b/lib/isccfg/include/isccfg/cfg.h index 82f35ba777..e79691aa97 100644 --- a/lib/isccfg/include/isccfg/cfg.h +++ b/lib/isccfg/include/isccfg/cfg.h @@ -15,7 +15,7 @@ * 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 @@ -245,7 +245,7 @@ cfg_obj_isstring(cfg_obj_t *obj); * 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 diff --git a/lib/isccfg/parser.c b/lib/isccfg/parser.c index 33c6840a15..ac9dc21468 100644 --- a/lib/isccfg/parser.c +++ b/lib/isccfg/parser.c @@ -15,7 +15,7 @@ * 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 */ @@ -806,7 +806,7 @@ cfg_obj_isstring(cfg_obj_t *obj) { 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);