diff --git a/CHANGES b/CHANGES index b2432938a6..3a249bc05b 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +3437. [bug] isc_buffer_init -> isc_buffer_constinit to initialise + buffers with constant data. [RT #32064] + 3436. [bug] Check malloc/calloc return values. [RT #32088] 3435. [bug] Cross compilation support in configure was broken. diff --git a/bin/check/check-tool.c b/bin/check/check-tool.c index 436fa683d1..1e534071d0 100644 --- a/bin/check/check-tool.c +++ b/bin/check/check-tool.c @@ -600,7 +600,7 @@ load_zone(isc_mem_t *mctx, const char *zonename, const char *filename, dns_zone_settype(zone, dns_zone_master); - isc_buffer_init(&buffer, zonename, strlen(zonename)); + isc_buffer_constinit(&buffer, zonename, strlen(zonename)); isc_buffer_add(&buffer, strlen(zonename)); dns_fixedname_init(&fixorigin); origin = dns_fixedname_name(&fixorigin); diff --git a/bin/named/config.c b/bin/named/config.c index eaba42b18a..1d15dde238 100644 --- a/bin/named/config.c +++ b/bin/named/config.c @@ -658,7 +658,7 @@ ns_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list, dns_name_init(keys[i - 1], NULL); keystr = cfg_obj_asstring(key); - isc_buffer_init(&b, keystr, strlen(keystr)); + isc_buffer_constinit(&b, keystr, strlen(keystr)); isc_buffer_add(&b, strlen(keystr)); dns_fixedname_init(&fname); result = dns_name_fromtext(dns_fixedname_name(&fname), &b, diff --git a/bin/named/lwresd.c b/bin/named/lwresd.c index 11198a4324..e4f90bc790 100644 --- a/bin/named/lwresd.c +++ b/bin/named/lwresd.c @@ -368,7 +368,7 @@ ns_lwdmanager_create(isc_mem_t *mctx, const cfg_obj_t *lwres, dns_fixedname_init(&fname); name = dns_fixedname_name(&fname); - isc_buffer_init(&namebuf, searchstr, + isc_buffer_constinit(&namebuf, searchstr, strlen(searchstr)); isc_buffer_add(&namebuf, strlen(searchstr)); result = dns_name_fromtext(name, &namebuf, diff --git a/bin/named/server.c b/bin/named/server.c index c84251781d..dcf0cbee90 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -523,7 +523,7 @@ configure_view_nametable(const cfg_obj_t *vconfig, const cfg_obj_t *config, element = cfg_list_next(element)) { nameobj = cfg_listelt_value(element); str = cfg_obj_asstring(nameobj); - isc_buffer_init(&b, str, strlen(str)); + isc_buffer_constinit(&b, str, strlen(str)); isc_buffer_add(&b, strlen(str)); CHECK(dns_name_fromtext(name, &b, dns_rootname, 0, NULL)); /* @@ -640,7 +640,7 @@ dstkey_fromconfig(const cfg_obj_t *vconfig, const cfg_obj_t *key, keystruct.common.rdtype, &keystruct, &rrdatabuf)); dns_fixedname_init(&fkeyname); - isc_buffer_init(&namebuf, keynamestr, strlen(keynamestr)); + isc_buffer_constinit(&namebuf, keynamestr, strlen(keynamestr)); isc_buffer_add(&namebuf, strlen(keynamestr)); CHECK(dns_name_fromtext(keyname, &namebuf, dns_rootname, 0, NULL)); CHECK(dst_key_fromdns(keyname, viewclass, &rrdatabuf, @@ -910,7 +910,7 @@ mustbesecure(const cfg_obj_t *mbs, dns_resolver_t *resolver) { { obj = cfg_listelt_value(element); str = cfg_obj_asstring(cfg_tuple_get(obj, "name")); - isc_buffer_init(&b, str, strlen(str)); + isc_buffer_constinit(&b, str, strlen(str)); isc_buffer_add(&b, strlen(str)); CHECK(dns_name_fromtext(name, &b, dns_rootname, 0, NULL)); value = cfg_obj_asboolean(cfg_tuple_get(obj, "value")); @@ -1063,7 +1063,7 @@ configure_order(dns_order_t *order, const cfg_obj_t *ent) { else str = "*"; addroot = ISC_TF(strcmp(str, "*") == 0); - isc_buffer_init(&b, str, strlen(str)); + isc_buffer_constinit(&b, str, strlen(str)); isc_buffer_add(&b, strlen(str)); dns_fixedname_init(&fixed); result = dns_name_fromtext(dns_fixedname_name(&fixed), &b, @@ -1249,7 +1249,7 @@ disable_algorithms(const cfg_obj_t *disabled, dns_resolver_t *resolver) { dns_fixedname_init(&fixed); name = dns_fixedname_name(&fixed); str = cfg_obj_asstring(cfg_tuple_get(disabled, "name")); - isc_buffer_init(&b, str, strlen(str)); + isc_buffer_constinit(&b, str, strlen(str)); isc_buffer_add(&b, strlen(str)); CHECK(dns_name_fromtext(name, &b, dns_rootname, 0, NULL)); @@ -1295,7 +1295,7 @@ disable_ds_digests(const cfg_obj_t *disabled, dns_resolver_t *resolver) { dns_fixedname_init(&fixed); name = dns_fixedname_name(&fixed); str = cfg_obj_asstring(cfg_tuple_get(disabled, "name")); - isc_buffer_init(&b, str, strlen(str)); + isc_buffer_constinit(&b, str, strlen(str)); isc_buffer_add(&b, strlen(str)); CHECK(dns_name_fromtext(name, &b, dns_rootname, 0, NULL)); @@ -1343,7 +1343,7 @@ on_disable_list(const cfg_obj_t *disablelist, dns_name_t *zonename) { { value = cfg_listelt_value(element); str = cfg_obj_asstring(value); - isc_buffer_init(&b, str, strlen(str)); + isc_buffer_constinit(&b, str, strlen(str)); isc_buffer_add(&b, strlen(str)); result = dns_name_fromtext(name, &b, dns_rootname, 0, NULL); @@ -1526,7 +1526,7 @@ dns64_reverse(dns_view_t *view, isc_mem_t *mctx, isc_netaddr_t *na, dns64_dbtype[3] = contact; dns_fixedname_init(&fixed); name = dns_fixedname_name(&fixed); - isc_buffer_init(&b, reverse, strlen(reverse)); + isc_buffer_constinit(&b, reverse, strlen(reverse)); isc_buffer_add(&b, strlen(reverse)); CHECK(dns_name_fromtext(name, &b, dns_rootname, 0, NULL)); CHECK(dns_zone_create(&zone, mctx)); @@ -2830,7 +2830,7 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig, obj = cfg_listelt_value(element); str = cfg_obj_asstring(cfg_tuple_get(obj, "trust-anchor")); - isc_buffer_init(&b, str, strlen(str)); + isc_buffer_constinit(&b, str, strlen(str)); isc_buffer_add(&b, strlen(str)); dlv = dns_fixedname_name(&view->dlv_fixed); CHECK(dns_name_fromtext(dlv, &b, dns_rootname, @@ -2883,7 +2883,7 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig, element = cfg_list_next(element)) { exclude = cfg_listelt_value(element); str = cfg_obj_asstring(exclude); - isc_buffer_init(&b, str, strlen(str)); + isc_buffer_constinit(&b, str, strlen(str)); isc_buffer_add(&b, strlen(str)); CHECK(dns_name_fromtext(name, &b, dns_rootname, 0, NULL)); @@ -2933,7 +2933,7 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig, result = ns_config_get(maps, "empty-server", &obj); if (result == ISC_R_SUCCESS) { str = cfg_obj_asstring(obj); - isc_buffer_init(&buffer, str, strlen(str)); + isc_buffer_constinit(&buffer, str, strlen(str)); isc_buffer_add(&buffer, strlen(str)); CHECK(dns_name_fromtext(name, &buffer, dns_rootname, 0, NULL)); @@ -2948,7 +2948,7 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig, result = ns_config_get(maps, "empty-contact", &obj); if (result == ISC_R_SUCCESS) { str = cfg_obj_asstring(obj); - isc_buffer_init(&buffer, str, strlen(str)); + isc_buffer_constinit(&buffer, str, strlen(str)); isc_buffer_add(&buffer, strlen(str)); CHECK(dns_name_fromtext(name, &buffer, dns_rootname, 0, NULL)); @@ -2971,7 +2971,7 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig, dns_forwarders_t *forwarders = NULL; dns_view_t *pview = NULL; - isc_buffer_init(&buffer, empty, strlen(empty)); + isc_buffer_constinit(&buffer, empty, strlen(empty)); isc_buffer_add(&buffer, strlen(empty)); /* * Look for zone on drop list. @@ -3198,7 +3198,7 @@ configure_alternates(const cfg_obj_t *config, dns_view_t *view, isc_buffer_t buffer; in_port_t myport = port; - isc_buffer_init(&buffer, str, strlen(str)); + isc_buffer_constinit(&buffer, str, strlen(str)); isc_buffer_add(&buffer, strlen(str)); dns_fixedname_init(&fixed); name = dns_fixedname_name(&fixed); @@ -3462,7 +3462,7 @@ configure_zone(const cfg_obj_t *config, const cfg_obj_t *zconfig, * Get the zone origin as a dns_name_t. */ zname = cfg_obj_asstring(cfg_tuple_get(zconfig, "name")); - isc_buffer_init(&buffer, zname, strlen(zname)); + isc_buffer_constinit(&buffer, zname, strlen(zname)); isc_buffer_add(&buffer, strlen(zname)); dns_fixedname_init(&fixorigin); CHECK(dns_name_fromtext(dns_fixedname_name(&fixorigin), @@ -4352,7 +4352,7 @@ configure_session_key(const cfg_obj_t **maps, ns_server_t *server, INSIST(result == ISC_R_SUCCESS); keynamestr = cfg_obj_asstring(obj); dns_fixedname_init(&fname); - isc_buffer_init(&buffer, keynamestr, strlen(keynamestr)); + isc_buffer_constinit(&buffer, keynamestr, strlen(keynamestr)); isc_buffer_add(&buffer, strlen(keynamestr)); keyname = dns_fixedname_name(&fname); result = dns_name_fromtext(keyname, &buffer, dns_rootname, 0, NULL); @@ -6177,7 +6177,7 @@ zone_from_args(ns_server_t *server, char *args, const char *zonetxt, viewtxt = next_token(&input, " \t"); } - isc_buffer_init(&buf, zonetxt, strlen(zonetxt)); + isc_buffer_constinit(&buf, zonetxt, strlen(zonetxt)); isc_buffer_add(&buf, strlen(zonetxt)); dns_fixedname_init(&name); result = dns_name_fromtext(dns_fixedname_name(&name), @@ -7114,7 +7114,7 @@ ns_server_flushnode(ns_server_t *server, char *args, isc_boolean_t tree) { if (target == NULL) return (ISC_R_UNEXPECTEDEND); - isc_buffer_init(&b, target, strlen(target)); + isc_buffer_constinit(&b, target, strlen(target)); isc_buffer_add(&b, strlen(target)); dns_fixedname_init(&fixed); name = dns_fixedname_name(&fixed); @@ -7787,7 +7787,7 @@ ns_server_add_zone(ns_server_t *server, char *args) { CHECK(cfg_map_get(config, "addzone", &parms)); zonename = cfg_obj_asstring(cfg_tuple_get(parms, "name")); - isc_buffer_init(&buf, zonename, strlen(zonename)); + isc_buffer_constinit(&buf, zonename, strlen(zonename)); isc_buffer_add(&buf, strlen(zonename)); dns_name_init(&dnsname, NULL); isc_buffer_allocate(server->mctx, &nbuf, 256); diff --git a/bin/named/tkeyconf.c b/bin/named/tkeyconf.c index 6d852a0871..f38d9420ba 100644 --- a/bin/named/tkeyconf.c +++ b/bin/named/tkeyconf.c @@ -73,7 +73,7 @@ ns_tkeyctx_fromconfig(const cfg_obj_t *options, isc_mem_t *mctx, if (result == ISC_R_SUCCESS) { s = cfg_obj_asstring(cfg_tuple_get(obj, "name")); n = cfg_obj_asuint32(cfg_tuple_get(obj, "keyid")); - isc_buffer_init(&b, s, strlen(s)); + isc_buffer_constinit(&b, s, strlen(s)); isc_buffer_add(&b, strlen(s)); dns_fixedname_init(&fname); name = dns_fixedname_name(&fname); @@ -87,7 +87,7 @@ ns_tkeyctx_fromconfig(const cfg_obj_t *options, isc_mem_t *mctx, result = cfg_map_get(options, "tkey-domain", &obj); if (result == ISC_R_SUCCESS) { s = cfg_obj_asstring(obj); - isc_buffer_init(&b, s, strlen(s)); + isc_buffer_constinit(&b, s, strlen(s)); isc_buffer_add(&b, strlen(s)); dns_fixedname_init(&fname); name = dns_fixedname_name(&fname); @@ -106,7 +106,7 @@ ns_tkeyctx_fromconfig(const cfg_obj_t *options, isc_mem_t *mctx, if (result == ISC_R_SUCCESS) { s = cfg_obj_asstring(obj); - isc_buffer_init(&b, s, strlen(s)); + isc_buffer_constinit(&b, s, strlen(s)); isc_buffer_add(&b, strlen(s)); dns_fixedname_init(&fname); name = dns_fixedname_name(&fname); diff --git a/bin/named/tsigconf.c b/bin/named/tsigconf.c index 776b1b9f83..5f9135d4d2 100644 --- a/bin/named/tsigconf.c +++ b/bin/named/tsigconf.c @@ -78,7 +78,7 @@ add_initial_keys(const cfg_obj_t *list, dns_tsig_keyring_t *ring, * Create the key name. */ dns_name_init(&keyname, NULL); - isc_buffer_init(&keynamesrc, keyid, strlen(keyid)); + isc_buffer_constinit(&keynamesrc, keyid, strlen(keyid)); isc_buffer_add(&keynamesrc, strlen(keyid)); isc_buffer_init(&keynamebuf, keynamedata, sizeof(keynamedata)); ret = dns_name_fromtext(&keyname, &keynamesrc, dns_rootname, diff --git a/bin/named/zoneconf.c b/bin/named/zoneconf.c index 6438bb3dd3..fff75d2107 100644 --- a/bin/named/zoneconf.c +++ b/bin/named/zoneconf.c @@ -269,7 +269,7 @@ configure_zone_ssutable(const cfg_obj_t *zconfig, dns_zone_t *zone, dns_fixedname_init(&fident); str = cfg_obj_asstring(identity); - isc_buffer_init(&b, str, strlen(str)); + isc_buffer_constinit(&b, str, strlen(str)); isc_buffer_add(&b, strlen(str)); result = dns_name_fromtext(dns_fixedname_name(&fident), &b, dns_rootname, 0, NULL); @@ -292,7 +292,7 @@ configure_zone_ssutable(const cfg_obj_t *zconfig, dns_zone_t *zone, } } else { str = cfg_obj_asstring(dname); - isc_buffer_init(&b, str, strlen(str)); + isc_buffer_constinit(&b, str, strlen(str)); isc_buffer_add(&b, strlen(str)); result = dns_name_fromtext(dns_fixedname_name(&fname), &b, dns_rootname, 0, NULL); @@ -525,7 +525,7 @@ configure_staticstub_servernames(const cfg_obj_t *zconfig, dns_zone_t *zone, dns_fixedname_init(&fixed_name); nsname = dns_fixedname_name(&fixed_name); - isc_buffer_init(&b, str, strlen(str)); + isc_buffer_constinit(&b, str, strlen(str)); isc_buffer_add(&b, strlen(str)); result = dns_name_fromtext(nsname, &b, dns_rootname, 0, NULL); if (result != ISC_R_SUCCESS) { diff --git a/bin/tests/db/t_db.c b/bin/tests/db/t_db.c index 54ef5a647d..37e67bacde 100644 --- a/bin/tests/db/t_db.c +++ b/bin/tests/db/t_db.c @@ -58,7 +58,7 @@ t_create(const char *db_type, const char *origin, const char *class, dns_fixedname_init(&dns_origin); len = strlen(origin); - isc_buffer_init(&origin_buffer, origin, len); + isc_buffer_constinit(&origin_buffer, origin, len); isc_buffer_add(&origin_buffer, len); dns_result = dns_name_fromtext(dns_fixedname_name(&dns_origin), &origin_buffer, NULL, 0, NULL); diff --git a/bin/tests/dst/dst_test.c b/bin/tests/dst/dst_test.c index ac1327c99f..ecea7b829c 100644 --- a/bin/tests/dst/dst_test.c +++ b/bin/tests/dst/dst_test.c @@ -54,7 +54,7 @@ use(dst_key_t *key, isc_mem_t *mctx) { */ isc_buffer_add(&sigbuf, 1); - isc_buffer_init(&databuf, data, strlen(data)); + isc_buffer_constinit(&databuf, data, strlen(data)); isc_buffer_add(&databuf, strlen(data)); isc_buffer_usedregion(&databuf, &datareg); @@ -262,7 +262,7 @@ main(void) { dns_fixedname_init(&fname); name = dns_fixedname_name(&fname); - isc_buffer_init(&b, "test.", 5); + isc_buffer_constinit(&b, "test.", 5); isc_buffer_add(&b, 5); result = dns_name_fromtext(name, &b, NULL, 0, NULL); if (result != ISC_R_SUCCESS) @@ -274,7 +274,7 @@ main(void) { io(name, 49667, DST_ALG_DSA, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC, mctx); io(name, 2, DST_ALG_RSAMD5, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC, mctx); - isc_buffer_init(&b, "dh.", 3); + isc_buffer_constinit(&b, "dh.", 3); isc_buffer_add(&b, 3); result = dns_name_fromtext(name, &b, NULL, 0, NULL); if (result != ISC_R_SUCCESS) diff --git a/bin/tests/dst/t_dst.c b/bin/tests/dst/t_dst.c index 75a2a40ff1..e431c951bb 100644 --- a/bin/tests/dst/t_dst.c +++ b/bin/tests/dst/t_dst.c @@ -104,7 +104,7 @@ use(dst_key_t *key, isc_mem_t *mctx, isc_result_t exp_result, int *nfails) { dst_context_t *ctx = NULL; isc_buffer_init(&sigbuf, sig, sizeof(sig)); - isc_buffer_init(&databuf, data, strlen(data)); + isc_buffer_constinit(&databuf, data, strlen(data)); isc_buffer_add(&databuf, strlen(data)); isc_buffer_usedregion(&databuf, &datareg); @@ -466,7 +466,7 @@ t1(void) { dns_fixedname_init(&fname); name = dns_fixedname_name(&fname); - isc_buffer_init(&b, "test.", 5); + isc_buffer_constinit(&b, "test.", 5); isc_buffer_add(&b, 5); isc_result = dns_name_fromtext(name, &b, NULL, 0, NULL); if (isc_result != ISC_R_SUCCESS) { @@ -488,7 +488,7 @@ t1(void) { io(name, 2, DST_ALG_RSAMD5, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC, mctx, DST_R_NULLKEY, &nfails, &nprobs); - isc_buffer_init(&b, "dh.", 3); + isc_buffer_constinit(&b, "dh.", 3); isc_buffer_add(&b, 3); isc_result = dns_name_fromtext(name, &b, NULL, 0, NULL); if (isc_result != ISC_R_SUCCESS) { @@ -750,7 +750,7 @@ t2_sigchk(char *datapath, char *sigpath, char *keyname, */ dns_fixedname_init(&fname); name = dns_fixedname_name(&fname); - isc_buffer_init(&b, keyname, strlen(keyname)); + isc_buffer_constinit(&b, keyname, strlen(keyname)); isc_buffer_add(&b, strlen(keyname)); isc_result = dns_name_fromtext(name, &b, dns_rootname, 0, NULL); if (isc_result != ISC_R_SUCCESS) { diff --git a/bin/tests/system/rsabigexponent/bigkey.c b/bin/tests/system/rsabigexponent/bigkey.c index 9136a330cb..b8984267e5 100644 --- a/bin/tests/system/rsabigexponent/bigkey.c +++ b/bin/tests/system/rsabigexponent/bigkey.c @@ -202,7 +202,7 @@ main(int argc, char **argv) { "isc_log_usechannel()"); dns_fixedname_init(&fname); name = dns_fixedname_name(&fname); - isc_buffer_init(&buf, "example.", strlen("example.")); + isc_buffer_constinit(&buf, "example.", strlen("example.")); isc_buffer_add(&buf, strlen("example.")); CHECK(dns_name_fromtext(name, &buf, dns_rootname, 0, NULL), "dns_name_fromtext(\"example.\")"); diff --git a/bin/tests/system/tkey/keycreate.c b/bin/tests/system/tkey/keycreate.c index a417a91b23..b1f3f34235 100644 --- a/bin/tests/system/tkey/keycreate.c +++ b/bin/tests/system/tkey/keycreate.c @@ -150,14 +150,14 @@ sendquery(isc_task_t *task, isc_event_t *event) { isc_sockaddr_fromin(&address, &inaddr, PORT); dns_fixedname_init(&keyname); - isc_buffer_init(&namestr, "tkeytest.", 9); + isc_buffer_constinit(&namestr, "tkeytest.", 9); isc_buffer_add(&namestr, 9); result = dns_name_fromtext(dns_fixedname_name(&keyname), &namestr, NULL, 0, NULL); CHECK("dns_name_fromtext", result); dns_fixedname_init(&ownername); - isc_buffer_init(&namestr, ownername_str, strlen(ownername_str)); + isc_buffer_constinit(&namestr, ownername_str, strlen(ownername_str)); isc_buffer_add(&namestr, strlen(ownername_str)); result = dns_name_fromtext(dns_fixedname_name(&ownername), &namestr, NULL, 0, NULL); diff --git a/contrib/dlz/drivers/sdlz_helper.c b/contrib/dlz/drivers/sdlz_helper.c index 85ad3b1c75..76dee7e36c 100644 --- a/contrib/dlz/drivers/sdlz_helper.c +++ b/contrib/dlz/drivers/sdlz_helper.c @@ -481,7 +481,7 @@ sdlzh_destroy_sqldbinstance(dbinstance_t *dbi) destroy_querylist(mctx, &dbi->lookup_q); /* get rid of the mutex */ - isc_mutex_destroy(&dbi->instance_lock); + (void) isc_mutex_destroy(&dbi->instance_lock); /* return, and detach the memory */ isc_mem_put(mctx, dbi, sizeof(dbinstance_t)); diff --git a/lib/bind9/check.c b/lib/bind9/check.c index 66fd3d2480..413686801f 100644 --- a/lib/bind9/check.c +++ b/lib/bind9/check.c @@ -100,7 +100,7 @@ check_orderent(const cfg_obj_t *ent, isc_log_t *logctx) { obj = cfg_tuple_get(ent, "name"); if (cfg_obj_isstring(obj)) { str = cfg_obj_asstring(obj); - isc_buffer_init(&b, str, strlen(str)); + isc_buffer_constinit(&b, str, strlen(str)); isc_buffer_add(&b, strlen(str)); tresult = dns_name_fromtext(dns_fixedname_name(&fixed), &b, dns_rootname, 0, NULL); @@ -197,7 +197,7 @@ check_dual_stack(const cfg_obj_t *options, isc_log_t *logctx) { continue; obj = cfg_tuple_get(value, "name"); str = cfg_obj_asstring(obj); - isc_buffer_init(&buffer, str, strlen(str)); + isc_buffer_constinit(&buffer, str, strlen(str)); isc_buffer_add(&buffer, strlen(str)); dns_fixedname_init(&fixed); name = dns_fixedname_name(&fixed); @@ -263,7 +263,7 @@ disabled_algorithms(const cfg_obj_t *disabled, isc_log_t *logctx) { name = dns_fixedname_name(&fixed); obj = cfg_tuple_get(disabled, "name"); str = cfg_obj_asstring(obj); - isc_buffer_init(&b, str, strlen(str)); + isc_buffer_constinit(&b, str, strlen(str)); isc_buffer_add(&b, strlen(str)); tresult = dns_name_fromtext(name, &b, dns_rootname, 0, NULL); if (tresult != ISC_R_SUCCESS) { @@ -311,7 +311,7 @@ disabled_ds_digests(const cfg_obj_t *disabled, isc_log_t *logctx) { name = dns_fixedname_name(&fixed); obj = cfg_tuple_get(disabled, "name"); str = cfg_obj_asstring(obj); - isc_buffer_init(&b, str, strlen(str)); + isc_buffer_constinit(&b, str, strlen(str)); isc_buffer_add(&b, strlen(str)); tresult = dns_name_fromtext(name, &b, dns_rootname, 0, NULL); if (tresult != ISC_R_SUCCESS) { @@ -395,7 +395,7 @@ mustbesecure(const cfg_obj_t *secure, isc_symtab_t *symtab, isc_log_t *logctx, name = dns_fixedname_name(&fixed); obj = cfg_tuple_get(secure, "name"); str = cfg_obj_asstring(obj); - isc_buffer_init(&b, str, strlen(str)); + isc_buffer_constinit(&b, str, strlen(str)); isc_buffer_add(&b, strlen(str)); result = dns_name_fromtext(name, &b, dns_rootname, 0, NULL); if (result != ISC_R_SUCCESS) { @@ -886,7 +886,7 @@ check_options(const cfg_obj_t *options, isc_log_t *logctx, isc_mem_t *mctx, element = cfg_list_next(element)) { exclude = cfg_listelt_value(element); str = cfg_obj_asstring(exclude); - isc_buffer_init(&b, str, strlen(str)); + isc_buffer_constinit(&b, str, strlen(str)); isc_buffer_add(&b, strlen(str)); tresult = dns_name_fromtext(name, &b, dns_rootname, @@ -971,7 +971,7 @@ check_options(const cfg_obj_t *options, isc_log_t *logctx, isc_mem_t *mctx, continue; } - isc_buffer_init(&b, dlv, strlen(dlv)); + isc_buffer_constinit(&b, dlv, strlen(dlv)); isc_buffer_add(&b, strlen(dlv)); tresult = dns_name_fromtext(name, &b, dns_rootname, 0, NULL); @@ -1005,7 +1005,7 @@ check_options(const cfg_obj_t *options, isc_log_t *logctx, isc_mem_t *mctx, if (!cfg_obj_isvoid(anchor)) { dlv = cfg_obj_asstring(anchor); - isc_buffer_init(&b, dlv, strlen(dlv)); + isc_buffer_constinit(&b, dlv, strlen(dlv)); isc_buffer_add(&b, strlen(dlv)); tresult = dns_name_fromtext(name, &b, dns_rootname, @@ -1079,7 +1079,7 @@ check_options(const cfg_obj_t *options, isc_log_t *logctx, isc_mem_t *mctx, (void)cfg_map_get(options, server_contact[i], &obj); if (obj != NULL) { str = cfg_obj_asstring(obj); - isc_buffer_init(&b, str, strlen(str)); + isc_buffer_constinit(&b, str, strlen(str)); isc_buffer_add(&b, strlen(str)); tresult = dns_name_fromtext(dns_fixedname_name(&fixed), &b, dns_rootname, 0, NULL); @@ -1103,7 +1103,7 @@ check_options(const cfg_obj_t *options, isc_log_t *logctx, isc_mem_t *mctx, { obj = cfg_listelt_value(element); str = cfg_obj_asstring(obj); - isc_buffer_init(&b, str, strlen(str)); + isc_buffer_constinit(&b, str, strlen(str)); isc_buffer_add(&b, strlen(str)); tresult = dns_name_fromtext(dns_fixedname_name(&fixed), &b, dns_rootname, 0, NULL); @@ -1288,7 +1288,7 @@ check_update_policy(const cfg_obj_t *policy, isc_log_t *logctx) { dns_fixedname_init(&fixed); str = cfg_obj_asstring(identity); - isc_buffer_init(&b, str, strlen(str)); + isc_buffer_constinit(&b, str, strlen(str)); isc_buffer_add(&b, strlen(str)); tresult = dns_name_fromtext(dns_fixedname_name(&fixed), &b, dns_rootname, 0, NULL); @@ -1302,7 +1302,7 @@ check_update_policy(const cfg_obj_t *policy, isc_log_t *logctx) { strcasecmp(cfg_obj_asstring(matchtype), "zonesub") != 0) { dns_fixedname_init(&fixed); str = cfg_obj_asstring(dname); - isc_buffer_init(&b, str, strlen(str)); + isc_buffer_constinit(&b, str, strlen(str)); isc_buffer_add(&b, strlen(str)); tresult = dns_name_fromtext(dns_fixedname_name(&fixed), &b, dns_rootname, 0, NULL); @@ -1548,7 +1548,7 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions, * deals with strings. */ dns_fixedname_init(&fixedname); - isc_buffer_init(&b, znamestr, strlen(znamestr)); + isc_buffer_constinit(&b, znamestr, strlen(znamestr)); isc_buffer_add(&b, strlen(znamestr)); tresult = dns_name_fromtext(dns_fixedname_name(&fixedname), &b, dns_rootname, DNS_NAME_DOWNCASE, NULL); @@ -1846,7 +1846,7 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions, snamestr = cfg_obj_asstring(obj); dns_fixedname_init(&fixed_sname); - isc_buffer_init(&b2, snamestr, strlen(snamestr)); + isc_buffer_constinit(&b2, snamestr, strlen(snamestr)); isc_buffer_add(&b2, strlen(snamestr)); sname = dns_fixedname_name(&fixed_sname); tresult = dns_name_fromtext(sname, &b2, dns_rootname, @@ -2038,7 +2038,7 @@ check_keylist(const cfg_obj_t *keys, isc_symtab_t *symtab, isc_buffer_t b; char *keyname; - isc_buffer_init(&b, keyid, strlen(keyid)); + isc_buffer_constinit(&b, keyid, strlen(keyid)); isc_buffer_add(&b, strlen(keyid)); tresult = dns_name_fromtext(name, &b, dns_rootname, 0, NULL); @@ -2207,7 +2207,7 @@ check_servers(const cfg_obj_t *config, const cfg_obj_t *voptions, */ keyval = cfg_obj_asstring(keys); dns_fixedname_init(&fname); - isc_buffer_init(&b, keyval, strlen(keyval)); + isc_buffer_constinit(&b, keyval, strlen(keyval)); isc_buffer_add(&b, strlen(keyval)); keyname = dns_fixedname_name(&fname); tresult = dns_name_fromtext(keyname, &b, dns_rootname, @@ -2252,7 +2252,7 @@ check_trusted_key(const cfg_obj_t *key, isc_boolean_t managed, keyname = dns_fixedname_name(&fkeyname); keynamestr = cfg_obj_asstring(cfg_tuple_get(key, "name")); - isc_buffer_init(&b, keynamestr, strlen(keynamestr)); + isc_buffer_constinit(&b, keynamestr, strlen(keynamestr)); isc_buffer_add(&b, strlen(keynamestr)); result = dns_name_fromtext(keyname, &b, dns_rootname, 0, NULL); if (result != ISC_R_SUCCESS) { diff --git a/lib/dns/dlz.c b/lib/dns/dlz.c index bb26537195..8da954cb45 100644 --- a/lib/dns/dlz.c +++ b/lib/dns/dlz.c @@ -507,7 +507,7 @@ dns_dlz_writeablezone(dns_view_t *view, dns_dlzdb_t *dlzdb, REQUIRE(dlzdb->configure_callback != NULL); - isc_buffer_init(&buffer, zone_name, strlen(zone_name)); + isc_buffer_constinit(&buffer, zone_name, strlen(zone_name)); isc_buffer_add(&buffer, strlen(zone_name)); dns_fixedname_init(&fixorigin); result = dns_name_fromtext(dns_fixedname_name(&fixorigin), diff --git a/lib/dns/name.c b/lib/dns/name.c index 46547829d9..7fb21e138c 100644 --- a/lib/dns/name.c +++ b/lib/dns/name.c @@ -2420,7 +2420,7 @@ dns_name_fromstring2(dns_name_t *target, const char *src, REQUIRE(src != NULL); - isc_buffer_init(&buf, src, strlen(src)); + isc_buffer_constinit(&buf, src, strlen(src)); isc_buffer_add(&buf, strlen(src)); if (BINDABLE(target) && target->buffer != NULL) name = target; diff --git a/lib/dns/peer.c b/lib/dns/peer.c index c55d73dddf..e6cbfe2727 100644 --- a/lib/dns/peer.c +++ b/lib/dns/peer.c @@ -533,7 +533,7 @@ dns_peer_setkeybycharp(dns_peer_t *peer, const char *keyval) { isc_result_t result; dns_fixedname_init(&fname); - isc_buffer_init(&b, keyval, strlen(keyval)); + isc_buffer_constinit(&b, keyval, strlen(keyval)); isc_buffer_add(&b, strlen(keyval)); result = dns_name_fromtext(dns_fixedname_name(&fname), &b, dns_rootname, 0, NULL); diff --git a/lib/dns/sdb.c b/lib/dns/sdb.c index cca5d836ed..bfc7a87168 100644 --- a/lib/dns/sdb.c +++ b/lib/dns/sdb.c @@ -382,7 +382,7 @@ dns_sdb_putrr(dns_sdblookup_t *lookup, const char *type, dns_ttl_t ttl, datalen = strlen(data); size = initial_size(datalen); do { - isc_buffer_init(&b, data, datalen); + isc_buffer_constinit(&b, data, datalen); isc_buffer_add(&b, datalen); result = isc_lex_openbuffer(lex, &b); if (result != ISC_R_SUCCESS) @@ -448,7 +448,7 @@ getnode(dns_sdballnodes_t *allnodes, const char *name, dns_sdbnode_t **nodep) { origin = &sdb->common.origin; else origin = dns_rootname; - isc_buffer_init(&b, name, strlen(name)); + isc_buffer_constinit(&b, name, strlen(name)); isc_buffer_add(&b, strlen(name)); result = dns_name_fromtext(newname, &b, origin, 0, NULL); diff --git a/lib/dns/sdlz.c b/lib/dns/sdlz.c index c80cce1caa..7ff4ee7264 100644 --- a/lib/dns/sdlz.c +++ b/lib/dns/sdlz.c @@ -1847,7 +1847,7 @@ dns_sdlz_putrr(dns_sdlzlookup_t *lookup, const char *type, dns_ttl_t ttl, size = initial_size(data); do { - isc_buffer_init(&b, data, strlen(data)); + isc_buffer_constinit(&b, data, strlen(data)); isc_buffer_add(&b, strlen(data)); result = isc_lex_openbuffer(lex, &b); @@ -1913,7 +1913,7 @@ dns_sdlz_putnamedrr(dns_sdlzallnodes_t *allnodes, const char *name, origin = &sdlz->common.origin; else origin = dns_rootname; - isc_buffer_init(&b, name, strlen(name)); + isc_buffer_constinit(&b, name, strlen(name)); isc_buffer_add(&b, strlen(name)); result = dns_name_fromtext(newname, &b, origin, 0, NULL); diff --git a/lib/dns/tests/dbiterator_test.c b/lib/dns/tests/dbiterator_test.c index 50fa9a251f..dc7b37058a 100644 --- a/lib/dns/tests/dbiterator_test.c +++ b/lib/dns/tests/dbiterator_test.c @@ -42,7 +42,7 @@ static isc_result_t make_name(const char *src, dns_name_t *name) { isc_buffer_t b; - isc_buffer_init(&b, src, strlen(src)); + isc_buffer_constinit(&b, src, strlen(src)); isc_buffer_add(&b, strlen(src)); return (dns_name_fromtext(name, &b, dns_rootname, 0, NULL)); } diff --git a/lib/dns/tests/dnstest.c b/lib/dns/tests/dnstest.c index 7235a49541..e403083457 100644 --- a/lib/dns/tests/dnstest.c +++ b/lib/dns/tests/dnstest.c @@ -214,7 +214,7 @@ dns_test_makezone(const char *name, dns_zone_t **zonep, dns_view_t *view, CHECK(dns_zone_create(&zone, mctx)); - isc_buffer_init(&buffer, name, strlen(name)); + isc_buffer_constinit(&buffer, name, strlen(name)); isc_buffer_add(&buffer, strlen(name)); dns_fixedname_init(&fixorigin); origin = dns_fixedname_name(&fixorigin); diff --git a/lib/export/samples/sample-request.c b/lib/export/samples/sample-request.c index fd1ba4cef8..46629f0328 100644 --- a/lib/export/samples/sample-request.c +++ b/lib/export/samples/sample-request.c @@ -82,7 +82,7 @@ make_querymessage(dns_message_t *message, const char *namestr, /* Construct qname */ namelen = strlen(namestr); - isc_buffer_init(&b, namestr, namelen); + isc_buffer_constinit(&b, namestr, namelen); isc_buffer_add(&b, namelen); dns_fixedname_init(&fixedqname); qname0 = dns_fixedname_name(&fixedqname); diff --git a/lib/export/samples/sample.c b/lib/export/samples/sample.c index 841f4f4c50..c7c542b1e5 100644 --- a/lib/export/samples/sample.c +++ b/lib/export/samples/sample.c @@ -204,7 +204,7 @@ addserver(dns_client_t *client, const char *addrstr, const char *namespace) { if (namespace != NULL) { namelen = strlen(namespace); - isc_buffer_init(&b, namespace, namelen); + isc_buffer_constinit(&b, namespace, namelen); isc_buffer_add(&b, namelen); dns_fixedname_init(&fname); name = dns_fixedname_name(&fname); diff --git a/lib/irs/dnsconf.c b/lib/irs/dnsconf.c index 4a7d58bfbc..3c1d8e6d32 100644 --- a/lib/irs/dnsconf.c +++ b/lib/irs/dnsconf.c @@ -144,8 +144,8 @@ configure_dnsseckeys(irs_dnsconf_t *conf, cfg_obj_t *cfgobj, /* Configure key name */ dns_fixedname_init(&fkeyname); keyname_base = dns_fixedname_name(&fkeyname); - isc_buffer_init(&namebuf, keynamestr, - strlen(keynamestr)); + isc_buffer_constinit(&namebuf, keynamestr, + strlen(keynamestr)); isc_buffer_add(&namebuf, strlen(keynamestr)); result = dns_name_fromtext(keyname_base, &namebuf, dns_rootname, 0, NULL); diff --git a/lib/irs/getaddrinfo.c b/lib/irs/getaddrinfo.c index b2ed946214..4e86706fe5 100644 --- a/lib/irs/getaddrinfo.c +++ b/lib/irs/getaddrinfo.c @@ -552,7 +552,7 @@ make_resstate(isc_mem_t *mctx, gai_statehead_t *head, const char *hostname, /* Construct base domain name */ namelen = strlen(domain); - isc_buffer_init(&b, domain, namelen); + isc_buffer_constinit(&b, domain, namelen); isc_buffer_add(&b, namelen); dns_fixedname_init(&fixeddomain); qdomain = dns_fixedname_name(&fixeddomain); @@ -564,7 +564,7 @@ make_resstate(isc_mem_t *mctx, gai_statehead_t *head, const char *hostname, /* Construct query name */ namelen = strlen(hostname); - isc_buffer_init(&b, hostname, namelen); + isc_buffer_constinit(&b, hostname, namelen); isc_buffer_add(&b, namelen); dns_fixedname_init(&state->fixedname); state->qname = dns_fixedname_name(&state->fixedname); diff --git a/lib/isc/buffer.c b/lib/isc/buffer.c index 1b59e650ac..eb57a658bc 100644 --- a/lib/isc/buffer.c +++ b/lib/isc/buffer.c @@ -28,7 +28,7 @@ #include void -isc__buffer_init(isc_buffer_t *b, const void *base, unsigned int length) { +isc__buffer_init(isc_buffer_t *b, void *base, unsigned int length) { /* * Make 'b' refer to the 'length'-byte region starting at 'base'. * XXXDCL see the comment in buffer.h about base being const. diff --git a/lib/isc/include/isc/buffer.h b/lib/isc/include/isc/buffer.h index ae7e4c3dfc..b382c82c97 100644 --- a/lib/isc/include/isc/buffer.h +++ b/lib/isc/include/isc/buffer.h @@ -222,7 +222,7 @@ isc_buffer_free(isc_buffer_t **dynbuffer); */ void -isc__buffer_init(isc_buffer_t *b, const void *base, unsigned int length); +isc__buffer_init(isc_buffer_t *b, void *base, unsigned int length); /*!< * \brief Make 'b' refer to the 'length'-byte region starting at base. * @@ -681,12 +681,7 @@ ISC_LANG_ENDDECLS */ #define ISC__BUFFER_INIT(_b, _base, _length) \ do { \ - union { \ - const void * konst; \ - void * var; \ - } _u; \ - _u.konst = (_base); \ - (_b)->base = _u.var; \ + (_b)->base = _base; \ (_b)->length = (_length); \ (_b)->used = 0; \ (_b)->current = 0; \ @@ -896,6 +891,13 @@ ISC_LANG_ENDDECLS #define isc_buffer_putuint32 isc__buffer_putuint32 #endif +#define isc_buffer_constinit(_b, _d, _l) \ + do { \ + union { void *_var; const void *_const; } _deconst; \ + _deconst._const = (_d); \ + isc_buffer_init((_b), _deconst._var, (_l)); \ + } while (0) + /* * No inline method for this one (yet). */ diff --git a/lib/isccfg/aclconf.c b/lib/isccfg/aclconf.c index 469989afce..af5659909e 100644 --- a/lib/isccfg/aclconf.c +++ b/lib/isccfg/aclconf.c @@ -192,7 +192,7 @@ convert_keyname(const cfg_obj_t *keyobj, isc_log_t *lctx, isc_mem_t *mctx, const char *txtname = cfg_obj_asstring(keyobj); keylen = strlen(txtname); - isc_buffer_init(&buf, txtname, keylen); + isc_buffer_constinit(&buf, txtname, keylen); isc_buffer_add(&buf, keylen); dns_fixedname_init(&fixname); result = dns_name_fromtext(dns_fixedname_name(&fixname), &buf,