2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-03 08:05:21 +00:00

2111. [bug] Fix a number of errors reported by Coverity.

[RT #16507]
This commit is contained in:
Mark Andrews
2006-12-07 04:46:27 +00:00
parent 1a8efeab76
commit cfcb0881d1
10 changed files with 35 additions and 28 deletions

View File

@@ -1,3 +1,6 @@
2111. [bug] Fix a number of errors reported by Coverity.
[RT #16507]
2110. [bug] "minimal-response yes;" interacted badly with BIND 8 2110. [bug] "minimal-response yes;" interacted badly with BIND 8
priming queries. [RT #16491] priming queries. [RT #16491]

View File

@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: controlconf.c,v 1.50 2006/02/28 02:39:51 marka Exp $ */ /* $Id: controlconf.c,v 1.51 2006/12/07 04:46:27 marka Exp $ */
/*! \file */ /*! \file */
@@ -690,7 +690,7 @@ controlkeylist_fromcfg(const cfg_obj_t *keylist, isc_mem_t *mctx,
char *newstr = NULL; char *newstr = NULL;
const char *str; const char *str;
const cfg_obj_t *obj; const cfg_obj_t *obj;
controlkey_t *key = NULL; controlkey_t *key;
for (element = cfg_list_first(keylist); for (element = cfg_list_first(keylist);
element != NULL; element != NULL;
@@ -709,7 +709,6 @@ controlkeylist_fromcfg(const cfg_obj_t *keylist, isc_mem_t *mctx,
key->secret.length = 0; key->secret.length = 0;
ISC_LINK_INIT(key, link); ISC_LINK_INIT(key, link);
ISC_LIST_APPEND(*keyids, key, link); ISC_LIST_APPEND(*keyids, key, link);
key = NULL;
newstr = NULL; newstr = NULL;
} }
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
@@ -717,8 +716,6 @@ controlkeylist_fromcfg(const cfg_obj_t *keylist, isc_mem_t *mctx,
cleanup: cleanup:
if (newstr != NULL) if (newstr != NULL)
isc_mem_free(mctx, newstr); isc_mem_free(mctx, newstr);
if (key != NULL)
isc_mem_put(mctx, key, sizeof(*key));
free_controlkeylist(keyids, mctx); free_controlkeylist(keyids, mctx);
return (ISC_R_NOMEMORY); return (ISC_R_NOMEMORY);
} }

View File

@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: lwdgrbn.c,v 1.16 2005/11/30 03:33:48 marka Exp $ */ /* $Id: lwdgrbn.c,v 1.17 2006/12/07 04:46:27 marka Exp $ */
/*! \file */ /*! \file */
@@ -185,8 +185,6 @@ iterate_node(lwres_grbnresponse_t *grbn, dns_db_t *db, dns_dbnode_t *node,
isc_mem_put(mctx, oldlens, oldsize * sizeof(*oldlens)); isc_mem_put(mctx, oldlens, oldsize * sizeof(*oldlens));
if (newrdatas != NULL) if (newrdatas != NULL)
isc_mem_put(mctx, newrdatas, used * sizeof(*oldrdatas)); isc_mem_put(mctx, newrdatas, used * sizeof(*oldrdatas));
if (newlens != NULL)
isc_mem_put(mctx, newlens, used * sizeof(*oldlens));
return (result); return (result);
} }

View File

@@ -16,7 +16,7 @@
*/ */
#if !defined(LINT) && !defined(CODECENTER) #if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "$Id: irp_ng.c,v 1.3 2005/04/27 04:56:28 sra Exp $"; static const char rcsid[] = "$Id: irp_ng.c,v 1.4 2006/12/07 04:46:27 marka Exp $";
#endif #endif
/* Imports */ /* Imports */
@@ -218,14 +218,14 @@ ng_test(struct irs_ng *this, const char *name,
} }
if (irs_irp_send_command(pvt->girpdata, "innetgr %s", body) == 0) { if (irs_irp_send_command(pvt->girpdata, "innetgr %s", body) == 0) {
memput(body, bodylen);
code = irs_irp_read_response(pvt->girpdata, text, sizeof text); code = irs_irp_read_response(pvt->girpdata, text, sizeof text);
if (code == IRPD_GETNETGR_MATCHES) { if (code == IRPD_GETNETGR_MATCHES) {
rval = 1; rval = 1;
} }
} }
memput(body, bodylen);
return (rval); return (rval);
} }

View File

@@ -1,5 +1,5 @@
#if !defined(lint) && !defined(SABER) #if !defined(lint) && !defined(SABER)
static const char rcsid[] = "$Id: ctl_srvr.c,v 1.7 2005/04/27 04:56:35 sra Exp $"; static const char rcsid[] = "$Id: ctl_srvr.c,v 1.8 2006/12/07 04:46:27 marka Exp $";
#endif /* not lint */ #endif /* not lint */
/* /*
@@ -564,7 +564,7 @@ static void
ctl_readable(evContext lev, void *uap, int fd, int evmask) { ctl_readable(evContext lev, void *uap, int fd, int evmask) {
static const char me[] = "ctl_readable"; static const char me[] = "ctl_readable";
struct ctl_sess *sess = uap; struct ctl_sess *sess = uap;
struct ctl_sctx *ctx = sess->ctx; struct ctl_sctx *ctx;
char *eos, tmp[MAX_NTOP]; char *eos, tmp[MAX_NTOP];
ssize_t n; ssize_t n;
@@ -572,6 +572,8 @@ ctl_readable(evContext lev, void *uap, int fd, int evmask) {
REQUIRE(fd >= 0); REQUIRE(fd >= 0);
REQUIRE(evmask == EV_READ); REQUIRE(evmask == EV_READ);
REQUIRE(sess->state == reading || sess->state == reading_data); REQUIRE(sess->state == reading || sess->state == reading_data);
ctx = sess->ctx;
evTouchIdleTimer(lev, sess->rdtiID); evTouchIdleTimer(lev, sess->rdtiID);
if (!allocated_p(sess->inbuf) && if (!allocated_p(sess->inbuf) &&
ctl_bufget(&sess->inbuf, ctx->logger) < 0) { ctl_bufget(&sess->inbuf, ctx->logger) < 0) {

View File

@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: master.c,v 1.159 2005/11/30 03:33:49 marka Exp $ */ /* $Id: master.c,v 1.160 2006/12/07 04:46:27 marka Exp $ */
/*! \file */ /*! \file */
@@ -1215,6 +1215,7 @@ load_text(dns_loadctx_t *lctx) {
isc_mem_free(mctx, gtype); isc_mem_free(mctx, gtype);
if (rhs != NULL) if (rhs != NULL)
isc_mem_free(mctx, rhs); isc_mem_free(mctx, rhs);
range = lhs = gtype = rhs = NULL;
/* RANGE */ /* RANGE */
GETTOKEN(lctx->lex, 0, &token, ISC_FALSE); GETTOKEN(lctx->lex, 0, &token, ISC_FALSE);
range = isc_mem_strdup(mctx, range = isc_mem_strdup(mctx,

View File

@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: sdb.c,v 1.53 2005/10/13 01:58:32 marka Exp $ */ /* $Id: sdb.c,v 1.54 2006/12/07 04:46:27 marka Exp $ */
/*! \file */ /*! \file */
@@ -935,7 +935,8 @@ find(dns_db_t *db, dns_name_t *name, dns_dbversion_t *version,
xresult = dns_name_copy(xname, foundname, NULL); xresult = dns_name_copy(xname, foundname, NULL);
if (xresult != ISC_R_SUCCESS) { if (xresult != ISC_R_SUCCESS) {
destroynode(node); if (node != NULL)
destroynode(node);
if (dns_rdataset_isassociated(rdataset)) if (dns_rdataset_isassociated(rdataset))
dns_rdataset_disassociate(rdataset); dns_rdataset_disassociate(rdataset);
return (DNS_R_BADDB); return (DNS_R_BADDB);

View File

@@ -50,7 +50,7 @@
* USE OR PERFORMANCE OF THIS SOFTWARE. * USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: sdlz.c,v 1.7 2005/11/30 03:33:49 marka Exp $ */ /* $Id: sdlz.c,v 1.8 2006/12/07 04:46:27 marka Exp $ */
/*! \file */ /*! \file */
@@ -894,7 +894,8 @@ find(dns_db_t *db, dns_name_t *name, dns_dbversion_t *version,
xresult = dns_name_copy(xname, foundname, NULL); xresult = dns_name_copy(xname, foundname, NULL);
if (xresult != ISC_R_SUCCESS) { if (xresult != ISC_R_SUCCESS) {
destroynode(node); if (node != NULL)
destroynode(node);
if (dns_rdataset_isassociated(rdataset)) if (dns_rdataset_isassociated(rdataset))
dns_rdataset_disassociate(rdataset); dns_rdataset_disassociate(rdataset);
return (DNS_R_BADDB); return (DNS_R_BADDB);

View File

@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: entropy.c,v 1.77 2006/03/02 23:25:05 marka Exp $ */ /* $Id: entropy.c,v 1.78 2006/12/07 04:46:27 marka Exp $ */
/* \file unix/entropy.c /* \file unix/entropy.c
* \brief * \brief
@@ -487,8 +487,6 @@ isc_entropy_createfilesource(isc_entropy_t *ent, const char *fname) {
LOCK(&ent->lock); LOCK(&ent->lock);
source = NULL;
if (stat(fname, &_stat) < 0) { if (stat(fname, &_stat) < 0) {
ret = isc__errno2result(errno); ret = isc__errno2result(errno);
goto errout; goto errout;
@@ -590,9 +588,6 @@ isc_entropy_createfilesource(isc_entropy_t *ent, const char *fname) {
(void)close(fd); (void)close(fd);
errout: errout:
if (source != NULL)
isc_mem_put(ent->mctx, source, sizeof(isc_entropysource_t));
UNLOCK(&ent->lock); UNLOCK(&ent->lock);
return (ret); return (ret);

View File

@@ -16,7 +16,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: cc.c,v 1.13 2005/04/29 00:23:55 marka Exp $ */ /* $Id: cc.c,v 1.14 2006/12/07 04:46:27 marka Exp $ */
/*! \file */ /*! \file */
@@ -468,12 +468,21 @@ createmessage(isc_uint32_t version, const char *from, const char *to,
result = ISC_R_NOMEMORY; result = ISC_R_NOMEMORY;
_ctrl = isccc_alist_create(); _ctrl = isccc_alist_create();
if (_ctrl == NULL)
goto bad;
if (isccc_alist_define(alist, "_ctrl", _ctrl) == NULL) {
isccc_sexpr_free(&_ctrl);
goto bad;
}
_data = isccc_alist_create(); _data = isccc_alist_create();
if (_ctrl == NULL || _data == NULL) if (_data == NULL)
goto bad; goto bad;
if (isccc_alist_define(alist, "_ctrl", _ctrl) == NULL || if (isccc_alist_define(alist, "_data", _data) == NULL) {
isccc_alist_define(alist, "_data", _data) == NULL) isccc_sexpr_free(&_data);
goto bad; goto bad;
}
if (isccc_cc_defineuint32(_ctrl, "_ser", serial) == NULL || if (isccc_cc_defineuint32(_ctrl, "_ser", serial) == NULL ||
isccc_cc_defineuint32(_ctrl, "_tim", now) == NULL || isccc_cc_defineuint32(_ctrl, "_tim", now) == NULL ||
(want_expires && (want_expires &&