From: Mark Andrews Date: Wed, 30 Nov 2005 03:44:39 +0000 (+0000) Subject: 1940. [bug] Fixed a number of error conditions reported by X-Git-Tag: v9.4.0a3~13 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=3c8367a203540b5209f6b63d714bb6ec4ba462c8;p=thirdparty%2Fbind9.git 1940. [bug] Fixed a number of error conditions reported by Coverity. --- diff --git a/CHANGES b/CHANGES index 70230cacda7..cc11506a393 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +1940. [bug] Fixed a number of error conditions reported by + Coverity. + 1939. [bug] The resolver could dereference a null pointer after validation if all the queries have timed out. [RT #15528] diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index 2043f7a002f..f76b6bccc91 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -16,7 +16,7 @@ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dnssec-signzone.c,v 1.177.18.14 2005/10/14 01:28:20 marka Exp $ */ +/* $Id: dnssec-signzone.c,v 1.177.18.15 2005/11/30 03:44:38 marka Exp $ */ /*! \file */ @@ -1271,10 +1271,6 @@ nsecify(void) { result = dns_dbiterator_next(dbiter); continue; } - if (result != ISC_R_SUCCESS) { - dns_db_detachnode(gdb, &nextnode); - break; - } if (!dns_name_issubdomain(nextname, gorigin) || (zonecut != NULL && dns_name_issubdomain(nextname, zonecut))) diff --git a/bin/named/config.c b/bin/named/config.c index fc66b07c31d..528466879f5 100644 --- a/bin/named/config.c +++ b/bin/named/config.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: config.c,v 1.47.18.15 2005/09/05 02:30:50 marka Exp $ */ +/* $Id: config.c,v 1.47.18.16 2005/11/30 03:44:38 marka Exp $ */ /*! \file */ @@ -448,13 +448,14 @@ ns_config_getipandkeylist(cfg_obj_t *config, cfg_obj_t *list, isc_mem_t *mctx, if (val > ISC_UINT16_MAX) { cfg_obj_log(portobj, ns_g_lctx, ISC_LOG_ERROR, "port '%u' out of range", val); - return (ISC_R_RANGE); + result = ISC_R_RANGE; + goto cleanup; } port = (in_port_t) val; } else { result = ns_config_getport(config, &port); if (result != ISC_R_SUCCESS) - return (result); + goto cleanup; } result = ISC_R_NOMEMORY; @@ -615,9 +616,9 @@ ns_config_getipandkeylist(cfg_obj_t *config, cfg_obj_t *list, isc_mem_t *mctx, if (new == NULL) goto cleanup; memcpy(new, addrs, newsize); - isc_mem_put(mctx, addrs, oldsize); } else new = NULL; + isc_mem_put(mctx, addrs, oldsize); addrs = new; addrcount = i; @@ -628,9 +629,9 @@ ns_config_getipandkeylist(cfg_obj_t *config, cfg_obj_t *list, isc_mem_t *mctx, if (new == NULL) goto cleanup; memcpy(new, keys, newsize); - isc_mem_put(mctx, keys, oldsize); } else new = NULL; + isc_mem_put(mctx, keys, oldsize); keys = new; keycount = i; } diff --git a/bin/named/controlconf.c b/bin/named/controlconf.c index d6c6df48458..c11c4a8e122 100644 --- a/bin/named/controlconf.c +++ b/bin/named/controlconf.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: controlconf.c,v 1.40.18.5 2005/08/23 02:31:30 marka Exp $ */ +/* $Id: controlconf.c,v 1.40.18.6 2005/11/30 03:44:38 marka Exp $ */ /*! \file */ @@ -364,6 +364,9 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) { { ccregion.rstart = isc_buffer_base(&conn->ccmsg.buffer); ccregion.rend = isc_buffer_used(&conn->ccmsg.buffer); + if (secret.rstart != NULL) + isc_mem_put(listener->mctx, secret.rstart, + REGION_SIZE(secret)); secret.rstart = isc_mem_get(listener->mctx, key->secret.length); if (secret.rstart == NULL) goto cleanup; @@ -379,8 +382,6 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) { */ if (request != NULL) isccc_sexpr_free(&request); - isc_mem_put(listener->mctx, secret.rstart, - REGION_SIZE(secret)); } else { log_invalid(&conn->ccmsg, result); goto cleanup; @@ -987,18 +988,25 @@ update_listener(ns_controls_t *cp, result = get_rndckey(listener->mctx, &listener->keys); } - if (result != ISC_R_SUCCESS && global_keylist != NULL) + if (result != ISC_R_SUCCESS && global_keylist != NULL) { /* * This message might be a little misleading since the * "new keys" might in fact be identical to the old ones, * but tracking whether they are identical just for the * sake of avoiding this message would be too much trouble. */ - cfg_obj_log(control, ns_g_lctx, ISC_LOG_WARNING, - "couldn't install new keys for " - "command channel %s: %s", - socktext, isc_result_totext(result)); - + if (control != NULL) + cfg_obj_log(control, ns_g_lctx, ISC_LOG_WARNING, + "couldn't install new keys for " + "command channel %s: %s", + socktext, isc_result_totext(result)); + else + isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, + NS_LOGMODULE_CONTROL, ISC_LOG_WARNING, + "couldn't install new keys for " + "command channel %s: %s", + socktext, isc_result_totext(result)); + } /* * Now, keep the old access list unless a new one can be made. @@ -1016,12 +1024,18 @@ update_listener(ns_controls_t *cp, dns_acl_detach(&listener->acl); dns_acl_attach(new_acl, &listener->acl); dns_acl_detach(&new_acl); - } else /* XXXDCL say the old acl is still used? */ + } else if (control != NULL) cfg_obj_log(control, ns_g_lctx, ISC_LOG_WARNING, "couldn't install new acl for " "command channel %s: %s", socktext, isc_result_totext(result)); + else + isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, + NS_LOGMODULE_CONTROL, ISC_LOG_WARNING, + "couldn't install new acl for " + "command channel %s: %s", + socktext, isc_result_totext(result)); if (result == ISC_R_SUCCESS && type == isc_sockettype_unix) { isc_uint32_t perm, owner, group; @@ -1037,7 +1051,7 @@ update_listener(ns_controls_t *cp, listener->perm = perm; listener->owner = owner; listener->group = group; - } else + } else if (control != NULL) cfg_obj_log(control, ns_g_lctx, ISC_LOG_WARNING, "couldn't update ownership/permission for " "command channel %s", socktext); diff --git a/bin/named/interfacemgr.c b/bin/named/interfacemgr.c index 31c392e0013..cd71e367feb 100644 --- a/bin/named/interfacemgr.c +++ b/bin/named/interfacemgr.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: interfacemgr.c,v 1.76.18.5 2005/04/27 05:00:30 sra Exp $ */ +/* $Id: interfacemgr.c,v 1.76.18.6 2005/11/30 03:44:38 marka Exp $ */ /*! \file */ @@ -766,9 +766,8 @@ do_scan(ns_interfacemgr_t *mgr, ns_listenlist_t *ext_listen, * See if the address matches the listen-on statement; * if not, ignore the interface. */ - result = dns_acl_match(&listen_netaddr, NULL, - le->acl, &mgr->aclenv, - &match, NULL); + (void)dns_acl_match(&listen_netaddr, NULL, le->acl, + &mgr->aclenv, &match, NULL); if (match <= 0) continue; @@ -799,9 +798,9 @@ do_scan(ns_interfacemgr_t *mgr, ns_listenlist_t *ext_listen, for (ele = ISC_LIST_HEAD(ext_listen->elts); ele != NULL; ele = ISC_LIST_NEXT(ele, link)) { - dns_acl_match(&listen_netaddr, NULL, - ele->acl, NULL, - &match, NULL); + (void)dns_acl_match(&listen_netaddr, + NULL, ele->acl, + NULL, &match, NULL); if (match > 0 && ele->port == le->port) break; else diff --git a/bin/named/lwdgrbn.c b/bin/named/lwdgrbn.c index 6d389f21394..a73f2403903 100644 --- a/bin/named/lwdgrbn.c +++ b/bin/named/lwdgrbn.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: lwdgrbn.c,v 1.13.18.2 2005/04/29 00:15:24 marka Exp $ */ +/* $Id: lwdgrbn.c,v 1.13.18.3 2005/11/30 03:44:38 marka Exp $ */ /*! \file */ @@ -360,7 +360,7 @@ lookup_done(isc_task_t *task, isc_event_t *event) { client->sendlength = r.length; result = ns_lwdclient_sendreply(client, &r); if (result != ISC_R_SUCCESS) - goto out; + goto out2; NS_LWDCLIENT_SETSEND(client); @@ -380,7 +380,7 @@ lookup_done(isc_task_t *task, isc_event_t *event) { if (grbn->siglen != NULL) isc_mem_put(cm->mctx, grbn->siglen, grbn->nsigs * sizeof(lwres_uint16_t)); - + out2: if (client->lookup != NULL) dns_lookup_destroy(&client->lookup); if (lwb.base != NULL) diff --git a/bin/named/lwresd.c b/bin/named/lwresd.c index 174fa8b347b..93773b81a1b 100644 --- a/bin/named/lwresd.c +++ b/bin/named/lwresd.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: lwresd.c,v 1.46.18.4 2005/08/23 02:31:33 marka Exp $ */ +/* $Id: lwresd.c,v 1.46.18.5 2005/11/30 03:44:38 marka Exp $ */ /*! \file * \brief @@ -408,6 +408,7 @@ ns_lwdmanager_create(isc_mem_t *mctx, cfg_obj_t *lwres, ns_lwsearchlist_detach(&lwresd->search); if (lwresd->mctx != NULL) isc_mem_detach(&lwresd->mctx); + isc_mem_put(mctx, lwresd, sizeof(ns_lwresd_t)); return (result); } diff --git a/bin/named/query.c b/bin/named/query.c index 0a8560504e9..309be4a3d29 100644 --- a/bin/named/query.c +++ b/bin/named/query.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: query.c,v 1.257.18.19 2005/11/02 01:37:35 marka Exp $ */ +/* $Id: query.c,v 1.257.18.20 2005/11/30 03:44:38 marka Exp $ */ /*! \file */ @@ -3270,7 +3270,9 @@ warn_rfc1918(ns_client_t *client, dns_name_t *fname, dns_rdataset_t *rdataset) { result = dns_rdataset_first(&found); RUNTIME_CHECK(result == ISC_R_SUCCESS); dns_rdataset_current(&found, &rdata); - dns_rdata_tostruct(&rdata, &soa, NULL); + result = dns_rdata_tostruct(&rdata, &soa, NULL); + if (result != ISC_R_SUCCESS) + return; if (dns_name_equal(&soa.origin, &prisoner) && dns_name_equal(&soa.contact, &hostmaster)) { char buf[DNS_NAME_FORMATSIZE]; diff --git a/bin/named/server.c b/bin/named/server.c index 16c4188cf9b..9588cdf17d2 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: server.c,v 1.419.18.32 2005/09/05 00:18:11 marka Exp $ */ +/* $Id: server.c,v 1.419.18.33 2005/11/30 03:44:38 marka Exp $ */ /*! \file */ @@ -277,7 +277,7 @@ configure_view_acl(cfg_obj_t *vconfig, cfg_obj_t *config, } maps[i] = NULL; - result = ns_config_get(maps, aclname, &aclobj); + (void)ns_config_get(maps, aclname, &aclobj); if (aclobj == NULL) /* * No value available. *aclp == NULL. @@ -496,7 +496,6 @@ get_view_querysource_dispatch(cfg_obj_t **maps, case AF_INET: result = ns_config_get(maps, "query-source", &obj); INSIST(result == ISC_R_SUCCESS); - break; case AF_INET6: result = ns_config_get(maps, "query-source-v6", &obj); @@ -905,7 +904,7 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig, * unless explicitly disabled. */ obj = NULL; - ns_config_get(maps, "use-additional-cache", &obj); + (void)ns_config_get(maps, "use-additional-cache", &obj); if (obj == NULL || cfg_obj_asboolean(obj)) { cmctx = NULL; CHECK(isc_mem_create(0, 0, &cmctx)); @@ -1282,7 +1281,7 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig, * Configure the "match-recursive-only" option. */ obj = NULL; - (void) ns_config_get(maps, "match-recursive-only", &obj); + (void)ns_config_get(maps, "match-recursive-only", &obj); if (obj != NULL && cfg_obj_asboolean(obj)) view->matchrecursiveonly = ISC_TRUE; else @@ -2249,8 +2248,7 @@ add_listenelt(isc_mem_t *mctx, ns_listenlist_t *list, isc_sockaddr_t *addr) { clean: INSIST(lelt == NULL); - if (src_acl != NULL) - dns_acl_detach(&src_acl); + dns_acl_detach(&src_acl); return (result); } @@ -4229,6 +4227,11 @@ ns_server_dumpdb(ns_server_t *server, char *args) { char *ptr; const char *sep; + /* Skip the command name. */ + ptr = next_token(&args, " \t"); + if (ptr == NULL) + return (ISC_R_UNEXPECTEDEND); + dctx = isc_mem_get(server->mctx, sizeof(*dctx)); if (dctx == NULL) return (ISC_R_NOMEMORY); @@ -4251,11 +4254,6 @@ ns_server_dumpdb(ns_server_t *server, char *args) { CHECKMF(isc_stdio_open(server->dumpfile, "w", &dctx->fp), "could not open dump file", server->dumpfile); - /* Skip the command name. */ - ptr = next_token(&args, " \t"); - if (ptr == NULL) - return (ISC_R_UNEXPECTEDEND); - sep = (args == NULL) ? "" : ": "; isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, ISC_LOG_INFO, diff --git a/bin/named/zoneconf.c b/bin/named/zoneconf.c index 8a124555725..34d54dbde0a 100644 --- a/bin/named/zoneconf.c +++ b/bin/named/zoneconf.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: zoneconf.c,v 1.110.18.14 2005/08/25 00:05:43 marka Exp $ */ +/* $Id: zoneconf.c,v 1.110.18.15 2005/11/30 03:44:38 marka Exp $ */ /*% */ @@ -730,6 +730,7 @@ ns_zone_configure(cfg_obj_t *config, cfg_obj_t *vconfig, cfg_obj_t *zconfig, switch (ztype) { case dns_zone_slave: case dns_zone_stub: + count = 0; obj = NULL; result = cfg_map_get(zoptions, "masters", &obj); if (obj != NULL) { diff --git a/bin/tests/db/t_db.c b/bin/tests/db/t_db.c index 747cacc9804..60bb24db4bb 100644 --- a/bin/tests/db/t_db.c +++ b/bin/tests/db/t_db.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: t_db.c,v 1.31.18.1 2004/10/25 01:32:24 marka Exp $ */ +/* $Id: t_db.c,v 1.31.18.2 2005/11/30 03:44:38 marka Exp $ */ #include @@ -403,8 +403,10 @@ test_dns_db_zc_x(const char *filename, dns_dbtype_t dbtype, /* * Skip comment lines. */ - if ((isspace((unsigned char)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) { + (void)free(p); continue; + } cnt = t_bustline(p, tokens); if (cnt == 4) { diff --git a/bin/tests/dst/dst_test.c b/bin/tests/dst/dst_test.c index ddc99e3b567..89f2a33a39b 100644 --- a/bin/tests/dst/dst_test.c +++ b/bin/tests/dst/dst_test.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dst_test.c,v 1.38.18.1 2004/06/11 00:30:11 marka Exp $ */ +/* $Id: dst_test.c,v 1.38.18.2 2005/11/30 03:44:38 marka Exp $ */ #include @@ -236,23 +236,34 @@ main(void) { isc_buffer_t b; dns_fixedname_t fname; dns_name_t *name; + isc_result_t result; - isc_mem_create(0, 0, &mctx); + result = isc_mem_create(0, 0, &mctx); + if (result != ISC_R_SUCCESS) + return (1); current = isc_mem_get(mctx, 256); + if (current == NULL) + return (1); getcwd(current, 256); dns_result_register(); - isc_entropy_create(mctx, &ectx); - isc_entropy_createfilesource(ectx, "randomfile"); + result = isc_entropy_create(mctx, &ectx); + if (result != ISC_R_SUCCESS) + return (1); + result = isc_entropy_createfilesource(ectx, "randomfile"); + if (result != ISC_R_SUCCESS) + return (1); dst_lib_init(mctx, ectx, ISC_ENTROPY_BLOCKING|ISC_ENTROPY_GOODONLY); dns_fixedname_init(&fname); name = dns_fixedname_name(&fname); isc_buffer_init(&b, "test.", 5); isc_buffer_add(&b, 5); - dns_name_fromtext(name, &b, NULL, ISC_FALSE, NULL); + result = dns_name_fromtext(name, &b, NULL, ISC_FALSE, NULL); + if (result != ISC_R_SUCCESS) + return (1); io(name, 23616, DST_ALG_DSA, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC, mctx); io(name, 54622, DST_ALG_RSAMD5, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC, mctx); @@ -262,7 +273,9 @@ main(void) { isc_buffer_init(&b, "dh.", 3); isc_buffer_add(&b, 3); - dns_name_fromtext(name, &b, NULL, ISC_FALSE, NULL); + result = dns_name_fromtext(name, &b, NULL, ISC_FALSE, NULL); + if (result != ISC_R_SUCCESS) + return (1); dh(name, 18602, name, 48957, mctx); generate(DST_ALG_RSAMD5, mctx); diff --git a/bin/tests/dst/t_dst.c b/bin/tests/dst/t_dst.c index 8e21d5e22be..87aff374066 100644 --- a/bin/tests/dst/t_dst.c +++ b/bin/tests/dst/t_dst.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: t_dst.c,v 1.48.18.1 2004/06/11 00:30:11 marka Exp $ */ +/* $Id: t_dst.c,v 1.48.18.2 2005/11/30 03:44:38 marka Exp $ */ #include @@ -405,7 +405,13 @@ t1(void) { name = dns_fixedname_name(&fname); isc_buffer_init(&b, "test.", 5); isc_buffer_add(&b, 5); - dns_name_fromtext(name, &b, NULL, ISC_FALSE, NULL); + isc_result = dns_name_fromtext(name, &b, NULL, ISC_FALSE, NULL); + if (isc_result != ISC_R_SUCCESS) { + t_info("dns_name_fromtext failed %s\n", + isc_result_totext(isc_result)); + t_result(T_UNRESOLVED); + return; + } io(name, 23616, DST_ALG_DSA, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC, mctx, ISC_R_SUCCESS, &nfails, &nprobs); t_info("testing use of stored keys [2]\n"); @@ -421,7 +427,13 @@ t1(void) { isc_buffer_init(&b, "dh.", 3); isc_buffer_add(&b, 3); - dns_name_fromtext(name, &b, NULL, ISC_FALSE, NULL); + isc_result = dns_name_fromtext(name, &b, NULL, ISC_FALSE, NULL); + if (isc_result != ISC_R_SUCCESS) { + t_info("dns_name_fromtext failed %s\n", + isc_result_totext(isc_result)); + t_result(T_UNRESOLVED); + return; + } dh(name, 18602, name, 48957, mctx, ISC_R_SUCCESS, &nfails, &nprobs); @@ -674,7 +686,14 @@ t2_sigchk(char *datapath, char *sigpath, char *keyname, name = dns_fixedname_name(&fname); isc_buffer_init(&b, keyname, strlen(keyname)); isc_buffer_add(&b, strlen(keyname)); - dns_name_fromtext(name, &b, dns_rootname, ISC_FALSE, NULL); + isc_result = dns_name_fromtext(name, &b, dns_rootname, ISC_FALSE, NULL); + if (isc_result != ISC_R_SUCCESS) { + t_info("dns_name_fromtext failed %s\n", + isc_result_totext(isc_result)); + (void) free(data); + ++*nprobs; + return; + } isc_result = dst_key_fromfile(name, id, alg, type, NULL, mctx, &key); if (isc_result != ISC_R_SUCCESS) { t_info("dst_key_fromfile failed %s\n", diff --git a/bin/tests/master/t_master.c b/bin/tests/master/t_master.c index 20b0548e9ba..806bf70be20 100644 --- a/bin/tests/master/t_master.c +++ b/bin/tests/master/t_master.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: t_master.c,v 1.32 2004/03/05 04:58:49 marka Exp $ */ +/* $Id: t_master.c,v 1.32.18.1 2005/11/30 03:44:38 marka Exp $ */ #include @@ -153,8 +153,10 @@ test_master_x(const char *filename) { /* * Skip comment lines. */ - if ((isspace(*p & 0xff)) || (*p == '#')) + if ((isspace(*p & 0xff)) || (*p == '#')) { + (void)free(p); continue; + } /* * Name of data file, origin, zclass, expected result. diff --git a/bin/tests/names/t_names.c b/bin/tests/names/t_names.c index 90ece31962c..54a8d25178c 100644 --- a/bin/tests/names/t_names.c +++ b/bin/tests/names/t_names.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: t_names.c,v 1.36.18.2 2005/04/29 00:15:46 marka Exp $ */ +/* $Id: t_names.c,v 1.36.18.3 2005/11/30 03:44:38 marka Exp $ */ #include @@ -568,8 +568,10 @@ t_dns_name_isabsolute(void) { /* * Skip comment lines. */ - if ((isspace((unsigned char)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) { + (void)free(p); continue; + } cnt = bustline(p, Tokens); if (cnt == 2) { @@ -679,8 +681,10 @@ t_dns_name_hash(void) { /* * Skip comment lines. */ - if ((isspace((unsigned char)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) { + (void)free(p); continue; + } cnt = bustline(p, Tokens); if (cnt == 4) { @@ -833,8 +837,10 @@ t_dns_name_fullcompare(void) { /* * Skip comment lines. */ - if ((isspace((unsigned char)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) { + (void)free(p); continue; + } cnt = bustline(p, Tokens); if (cnt == 6) { @@ -951,8 +957,10 @@ t_dns_name_compare(void) { /* * Skip comment lines. */ - if ((isspace((unsigned char)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) { + (void)free(p); continue; + } cnt = bustline(p, Tokens); if (cnt == 3) { @@ -1051,8 +1059,10 @@ t_dns_name_rdatacompare(void) { /* * Skip comment lines. */ - if ((isspace((unsigned char)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) { + (void)free(p); continue; + } cnt = bustline(p, Tokens); if (cnt == 3) { @@ -1147,8 +1157,10 @@ t_dns_name_issubdomain(void) { /* * Skip comment lines. */ - if ((isspace((unsigned char)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) { + (void)free(p); continue; + } cnt = bustline(p, Tokens); if (cnt == 3) { @@ -1228,8 +1240,10 @@ t_dns_name_countlabels(void) { /* * Skip comment lines. */ - if ((isspace((unsigned char)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) { + (void)free(p); continue; + } cnt = bustline(p, Tokens); if (cnt == 2) { @@ -1338,8 +1352,10 @@ t_dns_name_getlabel(void) { /* * Skip comment lines. */ - if ((isspace((unsigned char)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) { + (void)free(p); continue; + } cnt = bustline(p, Tokens); if (cnt == 4) { @@ -1466,8 +1482,10 @@ t_dns_name_getlabelsequence(void) { /* * Skip comment lines. */ - if ((isspace((unsigned char)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) { + (void)free(p); continue; + } cnt = bustline(p, Tokens); if (cnt == 5) { @@ -1554,8 +1572,10 @@ t_dns_name_fromregion(void) { /* * Skip comment lines. */ - if ((isspace((unsigned char)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) { + (void)free(p); continue; + } cnt = bustline(p, Tokens); if (cnt == 1) { @@ -1602,8 +1622,10 @@ t_dns_name_toregion(void) { /* * Skip comment lines. */ - if ((isspace((unsigned char)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) { + (void)free(p); continue; + } cnt = bustline(p, Tokens); if (cnt == 1) { @@ -1737,8 +1759,10 @@ t_dns_name_fromtext(void) { /* * Skip comment lines. */ - if ((isspace((unsigned char)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) { + (void)free(p); continue; + } cnt = bustline(p, Tokens); if (cnt == 4) { @@ -1871,8 +1895,10 @@ t_dns_name_totext(void) { /* * Skip comment lines. */ - if ((isspace((unsigned char)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) { + (void)free(p); continue; + } cnt = bustline(p, Tokens); if (cnt == 2) { @@ -2030,8 +2056,10 @@ t_dns_name_fromwire_x(const char *testfile, size_t buflen) { /* * Skip comment lines. */ - if ((isspace((unsigned char)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) { + (void)free(p); continue; + } cnt = bustline(p, Tokens); if (cnt == 6) { @@ -2223,8 +2251,10 @@ t_dns_name_towire_x(const char *testfile, size_t buflen) { /* * Skip comment lines. */ - if ((isspace((unsigned char)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) { + (void)free(p); continue; + } cnt = bustline(p, Tokens); if (cnt == 5) { diff --git a/bin/tests/rbt/t_rbt.c b/bin/tests/rbt/t_rbt.c index 49428936e09..037db9cdd4f 100644 --- a/bin/tests/rbt/t_rbt.c +++ b/bin/tests/rbt/t_rbt.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: t_rbt.c,v 1.25.18.1 2004/10/25 01:32:25 marka Exp $ */ +/* $Id: t_rbt.c,v 1.25.18.2 2005/11/30 03:44:38 marka Exp $ */ #include @@ -127,6 +127,7 @@ create_name(char *s, isc_mem_t *mctx, dns_name_t **dns_name) { isc_result_t result; isc_buffer_t source; isc_buffer_t target; + dns_name_t *name; nfails = 0; @@ -141,22 +142,26 @@ create_name(char *s, isc_mem_t *mctx, dns_name_t **dns_name) { * The buffer for the actual name will immediately follow the * name structure. */ - *dns_name = isc_mem_get(mctx, sizeof(**dns_name) + DNSNAMELEN); - if (*dns_name == NULL) { + name = isc_mem_get(mctx, sizeof(*name) + DNSNAMELEN); + if (name == NULL) { t_info("isc_mem_get failed\n"); ++nfails; - } + } else { - dns_name_init(*dns_name, NULL); - isc_buffer_init(&target, *dns_name + 1, DNSNAMELEN); + dns_name_init(name, NULL); + isc_buffer_init(&target, name + 1, DNSNAMELEN); - result = dns_name_fromtext(*dns_name, &source, dns_rootname, - ISC_FALSE, &target); + result = dns_name_fromtext(name, &source, dns_rootname, + ISC_FALSE, &target); - if (result != ISC_R_SUCCESS) { - ++nfails; - t_info("dns_name_fromtext(%s) failed %s\n", - s, dns_result_totext(result)); + if (result != ISC_R_SUCCESS) { + ++nfails; + t_info("dns_name_fromtext(%s) failed %s\n", + s, dns_result_totext(result)); + isc_mem_put(mctx, name, + sizeof(*name) + DNSNAMELEN); + } else + *dns_name = name; } } else { ++nfails; @@ -182,15 +187,17 @@ t1_add(char *name, dns_rbt_t *rbt, isc_mem_t *mctx, isc_result_t *dns_result) { nprobs = 0; if (name && dns_result) { - *dns_result = create_name(name, mctx, &dns_name); - if (*dns_result == ISC_R_SUCCESS) { + if (create_name(name, mctx, &dns_name) == 0) { if (T_debug) t_info("dns_rbt_addname succeeded\n"); *dns_result = dns_rbt_addname(rbt, dns_name, dns_name); + if (*dns_result != ISC_R_SUCCESS) { + delete_name(dns_name, mctx); + t_info("dns_rbt_addname failed %s\n", + dns_result_totext(*dns_result)); + ++nprobs; + } } else { - t_info("dns_rbt_addname failed %s\n", - dns_result_totext(*dns_result)); - delete_name(dns_name, mctx); ++nprobs; } } else { @@ -208,8 +215,7 @@ t1_delete(char *name, dns_rbt_t *rbt, isc_mem_t *mctx, nprobs = 0; if (name && dns_result) { - *dns_result = create_name(name, mctx, &dns_name); - if (*dns_result == ISC_R_SUCCESS) { + if (create_name(name, mctx, &dns_name) == 0) { *dns_result = dns_rbt_deletename(rbt, dns_name, ISC_FALSE); delete_name(dns_name, mctx); @@ -234,8 +240,7 @@ t1_search(char *name, dns_rbt_t *rbt, isc_mem_t *mctx, nprobs = 0; if (name && dns_result) { - *dns_result = create_name(name, mctx, &dns_searchname); - if (*dns_result == ISC_R_SUCCESS) { + if (create_name(name, mctx, &dns_searchname) == 0) { dns_fixedname_init(&dns_fixedname); dns_foundname = dns_fixedname_name(&dns_fixedname); data = NULL; @@ -281,7 +286,7 @@ rbt_init(char *filename, dns_rbt_t **rbt, isc_mem_t *mctx) { * Skip any comment lines. */ if ((*p == '#') || (*p == '\0') || (*p == ' ')) { - free(p); + (void)free(p); continue; } @@ -362,8 +367,7 @@ test_rbt_gen(char *filename, char *command, char *testname, if (strcmp(command, "create") == 0) { result = T_PASS; } else if (strcmp(command, "add") == 0) { - dns_result = create_name(testname, mctx, &dns_name); - if (dns_result == ISC_R_SUCCESS) { + if (create_name(testname, mctx, &dns_name) == 0) { dns_result = dns_rbt_addname(rbt, dns_name, dns_name); if (dns_result != ISC_R_SUCCESS) @@ -466,8 +470,10 @@ test_dns_rbt_x(const char *filename) { /* * Skip comment lines. */ - if ((isspace((unsigned char)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) { + (void)free(p); continue; + } /* * Name of db file, command, testname, @@ -976,8 +982,10 @@ test_dns_rbtnodechain_init(const char *filename) { /* * Skip comment lines. */ - if ((isspace((unsigned char)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) { + (void)free(p); continue; + } cnt = t_bustline(p, Tokens); if (cnt == 10) { @@ -1163,8 +1171,10 @@ test_dns_rbtnodechain_first(const char *filename) { /* * Skip comment lines. */ - if ((isspace((unsigned char)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) { + (void)free(p); continue; + } cnt = t_bustline(p, Tokens); if (cnt == 5) { @@ -1354,8 +1364,10 @@ test_dns_rbtnodechain_last(const char *filename) { /* * Skip comment lines. */ - if ((isspace((unsigned char)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) { + (void)free(p); continue; + } cnt = t_bustline(p, Tokens); if (cnt == 5) { @@ -1560,8 +1572,10 @@ test_dns_rbtnodechain_next(const char *filename) { /* * Skip comment lines. */ - if ((isspace((unsigned char)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) { + (void)free(p); continue; + } cnt = t_bustline(p, Tokens); if (cnt == 4) { @@ -1765,8 +1779,10 @@ test_dns_rbtnodechain_prev(const char *filename) { /* * Skip comment lines. */ - if ((isspace((unsigned char)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) { + (void)free(p); continue; + } cnt = t_bustline(p, Tokens); if (cnt == 4) { diff --git a/bin/tests/system/tkey/keycreate.c b/bin/tests/system/tkey/keycreate.c index e417e72c1cf..6936caecd4e 100644 --- a/bin/tests/system/tkey/keycreate.c +++ b/bin/tests/system/tkey/keycreate.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: keycreate.c,v 1.10.18.1 2004/06/11 00:30:12 marka Exp $ */ +/* $Id: keycreate.c,v 1.10.18.2 2005/11/30 03:44:38 marka Exp $ */ #include @@ -144,7 +144,9 @@ sendquery(isc_task_t *task, isc_event_t *event) { isc_event_free(&event); - inet_pton(AF_INET, "10.53.0.1", &inaddr); + result = ISC_R_FAILURE; + if (inet_pton(AF_INET, "10.53.0.1", &inaddr) != 1) + CHECK("inet_pton", result); isc_sockaddr_fromin(&address, &inaddr, PORT); dns_fixedname_init(&keyname); diff --git a/bin/tests/system/tkey/keydelete.c b/bin/tests/system/tkey/keydelete.c index 88ad2716bef..18b97f16318 100644 --- a/bin/tests/system/tkey/keydelete.c +++ b/bin/tests/system/tkey/keydelete.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: keydelete.c,v 1.6.18.1 2004/06/11 00:30:12 marka Exp $ */ +/* $Id: keydelete.c,v 1.6.18.2 2005/11/30 03:44:39 marka Exp $ */ #include @@ -118,7 +118,9 @@ sendquery(isc_task_t *task, isc_event_t *event) { isc_event_free(&event); - inet_pton(AF_INET, "10.53.0.1", &inaddr); + result = ISC_R_FAILURE; + if (inet_pton(AF_INET, "10.53.0.1", &inaddr) != 1) + CHECK("inet_pton", result); isc_sockaddr_fromin(&address, &inaddr, PORT); query = NULL; diff --git a/bin/tests/tasks/t_tasks.c b/bin/tests/tasks/t_tasks.c index 2bd8455cd1e..45f903974b3 100644 --- a/bin/tests/tasks/t_tasks.c +++ b/bin/tests/tasks/t_tasks.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: t_tasks.c,v 1.32.18.5 2005/07/19 06:20:19 marka Exp $ */ +/* $Id: t_tasks.c,v 1.32.18.6 2005/11/30 03:44:39 marka Exp $ */ #include @@ -2131,6 +2131,7 @@ t13(void) { #define T14_NTASKS 10 #define T14_EXCLTASK 6 +int t14_exclusiveerror = ISC_R_SUCCESS; int t14_error = 0; int t14_done = 0; @@ -2146,8 +2147,12 @@ t14_callback(isc_task_t *task, isc_event_t *event) { t_info("task enter %d\n", taskno); if (taskno == T14_EXCLTASK) { int i; - isc_task_beginexclusive(task); - t_info("task %d got exclusive access\n", taskno); + t14_exclusiveerror = isc_task_beginexclusive(task); + if (t14_exclusiveerror == ISC_R_SUCCESS) + t_info("task %d got exclusive access\n", taskno); + else + t_info("task %d failed to got exclusive access: %d\n", + taskno, t14_exclusiveerror); for (i = 0; i < T14_NTASKS; i++) { t_info("task %d state %d\n", i , t14_active[i]); if (t14_active[i]) @@ -2251,8 +2256,11 @@ t_tasks14(void) { isc_taskmgr_destroy(&manager); - if (t14_error) { - t_info("mutual access occurred\n"); + if (t14_exclusiveerror != ISC_R_SUCCESS || t14_error) { + if (t14_exclusiveerror != ISC_R_SUCCESS) + t_info("isc_task_beginexclusive() failed\n"); + if (t14_error) + t_info("mutual access occurred\n"); return(T_FAIL); } diff --git a/lib/dns/acache.c b/lib/dns/acache.c index d93619085e9..76cefdf37d9 100644 --- a/lib/dns/acache.c +++ b/lib/dns/acache.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: acache.c,v 1.3.2.8 2005/07/12 01:22:18 marka Exp $ */ +/* $Id: acache.c,v 1.3.2.9 2005/11/30 03:44:39 marka Exp $ */ #include @@ -1235,7 +1235,12 @@ dns_acache_createentry(dns_acache_t *acache, dns_db_t *origdb, return (result); }; - isc_refcount_init(&newentry->references, 1); + result = isc_refcount_init(&newentry->references, 1); + if (result != ISC_R_SUCCESS) { + ACACHE_DESTROYLOCK(&newentry->lock); + isc_mem_put(acache->mctx, newentry, sizeof(*newentry)); + return (result); + }; ISC_LINK_INIT(newentry, link); ISC_LINK_INIT(newentry, olink); diff --git a/lib/dns/adb.c b/lib/dns/adb.c index 403fa3b3a42..e1c5b0ad309 100644 --- a/lib/dns/adb.c +++ b/lib/dns/adb.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: adb.c,v 1.215.18.10 2005/10/14 05:26:54 marka Exp $ */ +/* $Id: adb.c,v 1.215.18.11 2005/11/30 03:44:39 marka Exp $ */ /*! \file * @@ -2594,8 +2594,7 @@ dns_adb_createfind(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action, } } - if (bucket != DNS_ADB_INVALIDBUCKET) - UNLOCK(&adb->namelocks[bucket]); + UNLOCK(&adb->namelocks[bucket]); return (result); } diff --git a/lib/dns/dnssec.c b/lib/dns/dnssec.c index 3763654cae6..fda70489cf9 100644 --- a/lib/dns/dnssec.c +++ b/lib/dns/dnssec.c @@ -16,7 +16,7 @@ */ /* - * $Id: dnssec.c,v 1.81.18.3 2005/04/29 00:15:50 marka Exp $ + * $Id: dnssec.c,v 1.81.18.4 2005/11/30 03:44:39 marka Exp $ */ /*! \file */ @@ -331,8 +331,7 @@ cleanup_array: cleanup_context: dst_context_destroy(&ctx); cleanup_databuf: - if (databuf != NULL) - isc_buffer_free(&databuf); + isc_buffer_free(&databuf); cleanup_signature: isc_mem_put(mctx, sig.signature, sig.siglen); diff --git a/lib/dns/dst_api.c b/lib/dns/dst_api.c index 552065bb1b4..dee48364aca 100644 --- a/lib/dns/dst_api.c +++ b/lib/dns/dst_api.c @@ -18,7 +18,7 @@ /* * Principal Author: Brian Wellington - * $Id: dst_api.c,v 1.1.6.4 2005/06/17 02:27:13 marka Exp $ + * $Id: dst_api.c,v 1.1.6.5 2005/11/30 03:44:39 marka Exp $ */ /*! \file */ @@ -416,6 +416,7 @@ dst_key_fromnamedfile(const char *filename, int type, isc_mem_t *mctx, result = dst_key_read_public(newfilename, type, mctx, &pubkey); isc_mem_put(mctx, newfilename, newfilenamelen); + newfilename = NULL; if (result != ISC_R_SUCCESS) return (result); @@ -1039,8 +1040,10 @@ write_public_key(const dst_key_t *key, int type, const char *directory) { } ret = dns_name_print(key->key_name, fp); - if (ret != ISC_R_SUCCESS) + if (ret != ISC_R_SUCCESS) { + fclose(fp); return (ret); + } fprintf(fp, " "); diff --git a/lib/dns/lookup.c b/lib/dns/lookup.c index 6156094033c..642a43450b4 100644 --- a/lib/dns/lookup.c +++ b/lib/dns/lookup.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: lookup.c,v 1.14.18.3 2005/04/29 00:15:58 marka Exp $ */ +/* $Id: lookup.c,v 1.14.18.4 2005/11/30 03:44:39 marka Exp $ */ /*! \file */ @@ -156,11 +156,6 @@ build_event(dns_lookup_t *lookup) { dns_rdataset_disassociate(rdataset); isc_mem_put(lookup->mctx, rdataset, sizeof(dns_rdataset_t)); } - if (sigrdataset != NULL) { - if (dns_rdataset_isassociated(sigrdataset)) - dns_rdataset_disassociate(sigrdataset); - isc_mem_put(lookup->mctx, sigrdataset, sizeof(dns_rdataset_t)); - } return (result); } @@ -231,13 +226,14 @@ lookup_find(dns_lookup_t *lookup, dns_fetchevent_t *event) { send_event = ISC_TRUE; goto done; } - } else { + } else if (event != NULL) { result = event->result; fname = dns_fixedname_name(&event->foundname); dns_resolver_destroyfetch(&lookup->fetch); INSIST(event->rdataset == &lookup->rdataset); INSIST(event->sigrdataset == &lookup->sigrdataset); - } + } else + fname = NULL; /* Silence compiler warning. */ /* * If we've been canceled, forget about the result. diff --git a/lib/dns/master.c b/lib/dns/master.c index 83c2e83b21a..82364f4aa43 100644 --- a/lib/dns/master.c +++ b/lib/dns/master.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: master.c,v 1.148.18.10 2005/09/01 03:04:27 marka Exp $ */ +/* $Id: master.c,v 1.148.18.11 2005/11/30 03:44:39 marka Exp $ */ /*! \file */ @@ -2172,6 +2172,10 @@ load_raw(dns_loadctx_t *lctx) { rdatalist.covers = isc_buffer_getuint16(&target); rdatalist.ttl = isc_buffer_getuint32(&target); rdcount = isc_buffer_getuint32(&target); + if (rdcount == 0) { + result = ISC_R_RANGE; + goto cleanup; + } INSIST(isc_buffer_consumedlength(&target) <= readlen); /* Owner name: length followed by name */ diff --git a/lib/dns/masterdump.c b/lib/dns/masterdump.c index fa315deb8a1..4c3e21f19b9 100644 --- a/lib/dns/masterdump.c +++ b/lib/dns/masterdump.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: masterdump.c,v 1.73.18.9 2005/10/21 03:19:35 marka Exp $ */ +/* $Id: masterdump.c,v 1.73.18.10 2005/11/30 03:44:39 marka Exp $ */ /*! \file */ @@ -1448,9 +1448,8 @@ dns_master_dumptostreaminc(isc_mem_t *mctx, dns_db_t *db, dns_dumpctx_attach(dctx, dctxp); return (DNS_R_CONTINUE); } - if (dctx != NULL) - dns_dumpctx_detach(&dctx); + dns_dumpctx_detach(&dctx); return (result); } diff --git a/lib/dns/message.c b/lib/dns/message.c index 194db02f09a..94e1debb0b0 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: message.c,v 1.222.18.5 2005/06/07 01:43:52 marka Exp $ */ +/* $Id: message.c,v 1.222.18.6 2005/11/30 03:44:39 marka Exp $ */ /*! \file */ @@ -808,6 +808,7 @@ dns_message_findtype(dns_name_t *name, dns_rdatatype_t type, { dns_rdataset_t *curr; + REQUIRE(name != NULL); if (rdataset != NULL) { REQUIRE(*rdataset == NULL); } diff --git a/lib/dns/opensslrsa_link.c b/lib/dns/opensslrsa_link.c index f75513e5d33..87cbb9eb7c3 100644 --- a/lib/dns/opensslrsa_link.c +++ b/lib/dns/opensslrsa_link.c @@ -17,7 +17,7 @@ /* * Principal Author: Brian Wellington - * $Id: opensslrsa_link.c,v 1.1.6.4 2005/06/17 02:27:14 marka Exp $ + * $Id: opensslrsa_link.c,v 1.1.6.5 2005/11/30 03:44:39 marka Exp $ */ #ifdef OPENSSL @@ -87,12 +87,16 @@ opensslrsa_createctx(dst_key_t *key, dst_context_t *dctx) { isc_md5_t *md5ctx; md5ctx = isc_mem_get(dctx->mctx, sizeof(isc_md5_t)); + if (md5ctx == NULL) + return (ISC_R_NOMEMORY); isc_md5_init(md5ctx); dctx->opaque = md5ctx; } else { isc_sha1_t *sha1ctx; sha1ctx = isc_mem_get(dctx->mctx, sizeof(isc_sha1_t)); + if (sha1ctx == NULL) + return (ISC_R_NOMEMORY); isc_sha1_init(sha1ctx); dctx->opaque = sha1ctx; } diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index e9581f4ad32..21f1bdec871 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: resolver.c,v 1.284.18.35 2005/11/03 00:57:59 marka Exp $ */ +/* $Id: resolver.c,v 1.284.18.36 2005/11/30 03:44:39 marka Exp $ */ /*! \file */ @@ -3309,6 +3309,7 @@ validated(isc_task_t *task, isc_event_t *event) { result = dns_rdataset_addnoqname(vevent->rdataset, vevent->proofs[DNS_VALIDATOR_NOQNAMEPROOF]); RUNTIME_CHECK(result == ISC_R_SUCCESS); + INSIST(vevent->sigrdataset != NULL); vevent->sigrdataset->ttl = vevent->rdataset->ttl; } diff --git a/lib/dns/sdlz.c b/lib/dns/sdlz.c index 6acbb7f53eb..88273a38d0d 100644 --- a/lib/dns/sdlz.c +++ b/lib/dns/sdlz.c @@ -50,7 +50,7 @@ * USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: sdlz.c,v 1.2.2.4 2005/11/02 23:29:50 marka Exp $ */ +/* $Id: sdlz.c,v 1.2.2.5 2005/11/30 03:44:39 marka Exp $ */ /*! \file */ @@ -1471,7 +1471,7 @@ dns_sdlz_putrr(dns_sdlzlookup_t *lookup, const char *type, dns_ttl_t ttl, dns_rdatatype_t typeval; isc_consttextregion_t r; isc_buffer_t b; - isc_buffer_t *rdatabuf; + isc_buffer_t *rdatabuf = NULL; isc_lex_t *lex; isc_result_t result; unsigned int size; diff --git a/lib/dns/tkey.c b/lib/dns/tkey.c index 41072290668..e4dbdc7bf24 100644 --- a/lib/dns/tkey.c +++ b/lib/dns/tkey.c @@ -16,7 +16,7 @@ */ /* - * $Id: tkey.c,v 1.76.18.4 2005/06/10 07:03:25 marka Exp $ + * $Id: tkey.c,v 1.76.18.5 2005/11/30 03:44:39 marka Exp $ */ /*! \file */ #include @@ -441,15 +441,17 @@ process_gsstkey(dns_message_t *msg, dns_name_t *signer, dns_name_t *name, dstkey, ISC_TRUE, signer, tkeyin->inception, tkeyin->expire, msg->mctx, ring, NULL); +#if 1 if (result != ISC_R_SUCCESS) goto failure; - +#else if (result == ISC_R_NOTFOUND) { tkeyout->error = dns_tsigerror_badalg; return (ISC_R_SUCCESS); } if (result != ISC_R_SUCCESS) goto failure; +#endif /* This key is good for a long time */ isc_stdtime_get(&now); diff --git a/lib/dns/tsig.c b/lib/dns/tsig.c index 9b94284d610..02ca7365d6f 100644 --- a/lib/dns/tsig.c +++ b/lib/dns/tsig.c @@ -16,7 +16,7 @@ */ /* - * $Id: tsig.c,v 1.117.18.4 2005/07/12 01:22:25 marka Exp $ + * $Id: tsig.c,v 1.117.18.5 2005/11/30 03:44:39 marka Exp $ */ /*! \file */ #include @@ -378,7 +378,7 @@ dns_tsig_sign(dns_message_t *msg) { isc_buffer_t databuf, sigbuf; isc_buffer_t *dynbuf; dns_name_t *owner; - dns_rdata_t *rdata; + dns_rdata_t *rdata = NULL; dns_rdatalist_t *datalist; dns_rdataset_t *dataset; isc_region_t r; @@ -570,7 +570,6 @@ dns_tsig_sign(dns_message_t *msg) { tsig.signature = NULL; } - rdata = NULL; ret = dns_message_gettemprdata(msg, &rdata); if (ret != ISC_R_SUCCESS) goto cleanup_signature; @@ -592,7 +591,7 @@ dns_tsig_sign(dns_message_t *msg) { owner = NULL; ret = dns_message_gettempname(msg, &owner); if (ret != ISC_R_SUCCESS) - goto cleanup_dynbuf; + goto cleanup_context; dns_name_init(owner, NULL); ret = dns_name_dup(&key->name, msg->mctx, owner); if (ret != ISC_R_SUCCESS) @@ -602,16 +601,16 @@ dns_tsig_sign(dns_message_t *msg) { 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; datalist->rdclass = dns_rdataclass_any; datalist->type = dns_rdatatype_tsig; datalist->covers = 0; datalist->ttl = 0; ISC_LIST_INIT(datalist->rdata); ISC_LIST_APPEND(datalist->rdata, rdata, link); - dataset = NULL; - ret = dns_message_gettemprdataset(msg, &dataset); - if (ret != ISC_R_SUCCESS) - goto cleanup_owner; dns_rdataset_init(dataset); RUNTIME_CHECK(dns_rdatalist_tordataset(datalist, dataset) == ISC_R_SUCCESS); @@ -620,18 +619,22 @@ dns_tsig_sign(dns_message_t *msg) { return (ISC_R_SUCCESS); -cleanup_owner: - if (owner != NULL) - dns_message_puttempname(msg, &owner); -cleanup_dynbuf: - if (dynbuf != NULL) - isc_buffer_free(&dynbuf); -cleanup_signature: + cleanup_rdatalist: + dns_message_puttemprdatalist(msg, &datalist); + cleanup_owner: + dns_message_puttempname(msg, &owner); + goto cleanup_context; + + cleanup_dynbuf: + isc_buffer_free(&dynbuf); + cleanup_signature: if (tsig.signature != NULL) isc_mem_put(mctx, tsig.signature, sigsize); -cleanup_context: - if (ctx != NULL) - dst_context_destroy(&ctx); + + cleanup_context: + if (rdata != NULL) + dns_message_puttemprdata(msg, &rdata); + dst_context_destroy(&ctx); return (ret); } diff --git a/lib/dns/validator.c b/lib/dns/validator.c index c0b9e2c69db..6c0abe06932 100644 --- a/lib/dns/validator.c +++ b/lib/dns/validator.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: validator.c,v 1.119.18.16 2005/11/03 00:57:59 marka Exp $ */ +/* $Id: validator.c,v 1.119.18.17 2005/11/30 03:44:39 marka Exp $ */ /*! \file */ @@ -2819,7 +2819,7 @@ dns_validator_create(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type, cleanup_event: isc_task_detach(&tclone); - isc_event_free((isc_event_t **)&val->event); + isc_event_free((isc_event_t **)&event); cleanup_val: dns_view_weakdetach(&val->view); diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 6e5e8f1a91f..37bb72be622 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: zone.c,v 1.410.18.35 2005/08/25 00:05:45 marka Exp $ */ +/* $Id: zone.c,v 1.410.18.36 2005/11/30 03:44:39 marka Exp $ */ /*! \file */ @@ -832,12 +832,10 @@ dns_zone_setdbtype(dns_zone_t *zone, nomem: if (new != NULL) { - for (i = 0; i < dbargc; i++) { - if (zone->db_argv[i] != NULL) + for (i = 0; i < dbargc; i++) + if (new[i] != NULL) isc_mem_free(zone->mctx, new[i]); - isc_mem_put(zone->mctx, new, - dbargc * sizeof(*new)); - } + isc_mem_put(zone->mctx, new, dbargc * sizeof(*new)); } result = ISC_R_NOMEMORY; @@ -1326,10 +1324,12 @@ zone_startload(dns_db_t *db, dns_zone_t *zone, isc_time_t loadtime) { zone_gotreadhandle, load, &zone->readio); if (result != ISC_R_SUCCESS) { - tresult = dns_db_endload(load->db, - &load->callbacks.add_private); - if (result == ISC_R_SUCCESS) - result = tresult; + /* + * We can't report multiple errors so ignore + * the result of dns_db_endload(). + */ + (void)dns_db_endload(load->db, + &load->callbacks.add_private); goto cleanup; } else result = DNS_R_CONTINUE; @@ -2853,6 +2853,7 @@ dns_zone_refresh(dns_zone_t *zone) { isc_interval_t i; isc_uint32_t oldflags; unsigned int j; + isc_result_t result; REQUIRE(DNS_ZONE_VALID(zone)); @@ -2886,7 +2887,11 @@ dns_zone_refresh(dns_zone_t *zone) { */ isc_interval_set(&i, isc_random_jitter(zone->retry, zone->retry / 4), 0); - isc_time_nowplusinterval(&zone->refreshtime, &i); + result = isc_time_nowplusinterval(&zone->refreshtime, &i); + if (result |= ISC_R_SUCCESS) + dns_zone_log(zone, ISC_LOG_WARNING, + "isc_time_nowplusinterval() failed: %s", + dns_result_totext(result)); /* * When lacking user-specified timer values from the SOA, diff --git a/lib/dns/zt.c b/lib/dns/zt.c index f1057837c2c..4cb8f3fc28d 100644 --- a/lib/dns/zt.c +++ b/lib/dns/zt.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: zt.c,v 1.38.18.4 2005/07/12 01:22:27 marka Exp $ */ +/* $Id: zt.c,v 1.38.18.5 2005/11/30 03:44:39 marka Exp $ */ /*! \file */ @@ -380,9 +380,8 @@ dns_zt_apply2(dns_zt_t *zt, isc_boolean_t stop, isc_result_t *sub, tresult = result; goto cleanup; /* don't break */ } else if (result != ISC_R_SUCCESS && - tresult != ISC_R_SUCCESS) + tresult == ISC_R_SUCCESS) tresult = result; - } result = dns_rbtnodechain_next(&chain, NULL, NULL); } diff --git a/lib/isc/lex.c b/lib/isc/lex.c index a335daab9a2..2e4e48ae334 100644 --- a/lib/isc/lex.c +++ b/lib/isc/lex.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: lex.c,v 1.78.18.4 2005/06/04 00:39:04 marka Exp $ */ +/* $Id: lex.c,v 1.78.18.5 2005/11/30 03:44:39 marka Exp $ */ /*! \file */ @@ -374,9 +374,6 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) { source = HEAD(lex->sources); REQUIRE(tokenp != NULL); - lex->saved_paren_count = lex->paren_count; - source->saved_line = source->line; - if (source == NULL) { if ((options & ISC_LEXOPT_NOMORE) != 0) { tokenp->type = isc_tokentype_nomore; @@ -388,6 +385,9 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) { if (source->result != ISC_R_SUCCESS) return (source->result); + lex->saved_paren_count = lex->paren_count; + source->saved_line = source->line; + if (isc_buffer_remaininglength(source->pushback) == 0 && source->at_eof) { @@ -627,10 +627,10 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) { (lex->data[0] != '0'))) { /* Above test supports hex numbers */ state = lexstate_string; - } else if ((options & ISC_LEXOPT_OCTAL) != 0 && - (c == '8' || c == '9')) { - state = lexstate_string; } + } else if ((options & ISC_LEXOPT_OCTAL) != 0 && + (c == '8' || c == '9')) { + state = lexstate_string; } if (remaining == 0U) { result = grow_data(lex, &remaining, @@ -644,9 +644,13 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) { remaining--; break; case lexstate_string: - if ((!escaped && - (c == ' ' || c == '\t' || lex->specials[c])) || - c == '\r' || c == '\n' || c == EOF) { + /* + * EOF needs to be checked before lex->specials[c] + * as lex->specials[EOF] is not a good idea. + */ + if (c == '\r' || c == '\n' || c == EOF || + (!escaped && + (c == ' ' || c == '\t' || lex->specials[c]))) { pushback(source, c); if (source->result != ISC_R_SUCCESS) { result = source->result; diff --git a/lib/isc/taskpool.c b/lib/isc/taskpool.c index 57d289df676..f1f619d26dc 100644 --- a/lib/isc/taskpool.c +++ b/lib/isc/taskpool.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: taskpool.c,v 1.12.18.2 2005/04/29 00:16:51 marka Exp $ */ +/* $Id: taskpool.c,v 1.12.18.3 2005/11/30 03:44:39 marka Exp $ */ /*! \file */ @@ -54,6 +54,10 @@ isc_taskpool_create(isc_taskmgr_t *tmgr, isc_mem_t *mctx, pool->mctx = mctx; pool->ntasks = ntasks; pool->tasks = isc_mem_get(mctx, ntasks * sizeof(isc_task_t *)); + if (pool->tasks == NULL) { + isc_mem_put(mctx, pool, sizeof(*pool)); + return (ISC_R_NOMEMORY); + } for (i = 0; i < ntasks; i++) pool->tasks[i] = NULL; for (i = 0; i < ntasks; i++) { diff --git a/lib/isc/timer.c b/lib/isc/timer.c index 69ebadc321d..4b96fa5e4ef 100644 --- a/lib/isc/timer.c +++ b/lib/isc/timer.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: timer.c,v 1.73.18.4 2005/10/26 06:50:49 marka Exp $ */ +/* $Id: timer.c,v 1.73.18.5 2005/11/30 03:44:39 marka Exp $ */ /*! \file */ @@ -214,9 +214,10 @@ schedule(isc_timer_t *timer, isc_time_t *now, isc_boolean_t signal_ok) { isc_time_t then; isc_interval_set(&fifteen, 15, 0); - isc_time_add(&manager->due, &fifteen, &then); + result = isc_time_add(&manager->due, &fifteen, &then); - if (isc_time_compare(&then, now) < 0) { + if (result == ISC_R_SUCCESS && + isc_time_compare(&then, now) < 0) { SIGNAL(&manager->wakeup); signal_ok = ISC_FALSE; isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL, @@ -349,8 +350,10 @@ isc_timer_create(isc_timermgr_t *manager, isc_timertype_t type, if (type == isc_timertype_once && !isc_interval_iszero(interval)) { result = isc_time_add(&now, interval, &timer->idle); - if (result != ISC_R_SUCCESS) + if (result != ISC_R_SUCCESS) { + isc_mem_put(manager->mctx, timer, sizeof(*timer)); return (result); + } } else isc_time_settoepoch(&timer->idle); diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index da892909047..4021d4a086c 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: socket.c,v 1.237.18.19 2005/11/03 23:02:23 marka Exp $ */ +/* $Id: socket.c,v 1.237.18.20 2005/11/30 03:44:39 marka Exp $ */ /*! \file */ @@ -2716,8 +2716,8 @@ socket_send(isc_socket_t *sock, isc_socketevent_t *dev, isc_task_t *task, dev->attributes |= ISC_SOCKEVENTATTR_PKTINFO; dev->pktinfo = *pktinfo; - if (!isc_sockaddr_issitelocal(address) && - !isc_sockaddr_islinklocal(address)) { + if (!isc_sockaddr_issitelocal(&dev->address) && + !isc_sockaddr_islinklocal(&dev->address)) { socket_log(sock, NULL, TRACE, isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_PKTINFOPROVIDED, "pktinfo structure provided, ifindex %u " diff --git a/lib/isccfg/parser.c b/lib/isccfg/parser.c index 8677350f56f..676deb2e69a 100644 --- a/lib/isccfg/parser.c +++ b/lib/isccfg/parser.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: parser.c,v 1.112.18.7 2005/09/05 00:18:31 marka Exp $ */ +/* $Id: parser.c,v 1.112.18.8 2005/11/30 03:44:39 marka Exp $ */ /*! \file */ @@ -1569,12 +1569,19 @@ parse_token(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) { isc_lex_getlasttokentext(pctx->lexer, &pctx->token, &r); obj->value.string.base = isc_mem_get(pctx->mctx, r.length + 1); + if (obj->value.string.base == NULL) { + result = ISC_R_NOMEMORY; + goto cleanup; + } obj->value.string.length = r.length; memcpy(obj->value.string.base, r.base, r.length); obj->value.string.base[r.length] = '\0'; *ret = obj; + return (result); cleanup: + if (obj != NULL) + isc_mem_put(pctx->mctx, obj, sizeof(*obj)); return (result); } @@ -1809,8 +1816,6 @@ cfg_doc_netaddr(cfg_printer_t *pctx, const cfg_type_t *type) { if (*flagp != CFG_ADDR_V4OK && *flagp != CFG_ADDR_V6OK) cfg_print_chars(pctx, "( ", 2); if (*flagp & CFG_ADDR_V4OK) { - if (n != 0) - cfg_print_chars(pctx, " | ", 3); cfg_print_cstr(pctx, ""); n++; } @@ -1997,8 +2002,6 @@ cfg_doc_sockaddr(cfg_printer_t *pctx, const cfg_type_t *type) { int n = 0; cfg_print_chars(pctx, "( ", 2); if (*flagp & CFG_ADDR_V4OK) { - if (n != 0) - cfg_print_chars(pctx, " | ", 3); cfg_print_cstr(pctx, ""); n++; } @@ -2291,7 +2294,6 @@ create_map(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) { CHECK(isc_symtab_create(pctx->mctx, 5, /* XXX */ map_symtabitem_destroy, pctx, ISC_FALSE, &symtab)); - obj->value.map.symtab = symtab; obj->value.map.id = NULL; diff --git a/lib/lwres/getaddrinfo.c b/lib/lwres/getaddrinfo.c index a4716af7c87..1a191a3a772 100644 --- a/lib/lwres/getaddrinfo.c +++ b/lib/lwres/getaddrinfo.c @@ -18,7 +18,7 @@ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: getaddrinfo.c,v 1.43.18.3 2005/06/08 02:07:58 marka Exp $ */ +/* $Id: getaddrinfo.c,v 1.43.18.4 2005/11/30 03:44:39 marka Exp $ */ /*! \file */ @@ -438,8 +438,10 @@ lwres_getaddrinfo(const char *hostname, const char *servname, NULL, 0, NI_NUMERICHOST) == 0) { ai->ai_canonname = strdup(nbuf); - if (ai->ai_canonname == NULL) + if (ai->ai_canonname == NULL) { + lwres_freeaddrinfo(ai_list); return (EAI_MEMORY); + } } else { /* XXX raise error? */ ai->ai_canonname = NULL; diff --git a/lib/tests/t_api.c b/lib/tests/t_api.c index 4383a8fca97..9e896d443c1 100644 --- a/lib/tests/t_api.c +++ b/lib/tests/t_api.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: t_api.c,v 1.52.18.5 2005/06/17 02:27:16 marka Exp $ */ +/* $Id: t_api.c,v 1.52.18.6 2005/11/30 03:44:39 marka Exp $ */ /*! \file */ @@ -542,7 +542,11 @@ t_fgetbs(FILE *fp) { } } *p = '\0'; - return(((c == EOF) && (n == 0U)) ? NULL : buf); + if (c == EOF && n == 0U) { + free(buf); + return (NULL); + } + return (buf); } else { fprintf(stderr, "malloc failed %d", errno); return(NULL); @@ -749,8 +753,10 @@ t_eval(const char *filename, int (*func)(char **), int nargs) { /* * Skip comment lines. */ - if ((isspace((unsigned char)*p)) || (*p == '#')) + if ((isspace((unsigned char)*p)) || (*p == '#')) { + (void)free(p); continue; + } cnt = t_bustline(p, tokens); if (cnt == nargs) {