From 938aea1dc406d525d0c2bbdd4e71f52a942f97c6 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Sat, 26 Oct 2013 10:04:36 +1100 Subject: [PATCH] address memory leak in change #3662, force format matching, attempt to address coverity false positives --- bin/dig/dighost.c | 14 ++++++++------ lib/dns/rdata/generic/isdn_20.c | 2 +- lib/dns/zone.c | 3 +++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 4b87a97277..aa1f70e951 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -543,8 +543,8 @@ debug(const char *format, ...) { if (debugtiming) { struct timeval tv; (void)gettimeofday(&tv, NULL); - fprintf(stderr, "%ld.%06d: ", (long)tv.tv_sec, - tv.tv_usec); + fprintf(stderr, "%ld.%06ld: ", (long)tv.tv_sec, + (long)tv.tv_usec); } va_start(args, format); vfprintf(stderr, format, args); @@ -2829,11 +2829,13 @@ launch_next_query(dig_query_t *query, isc_boolean_t include_question) { isc_buffer_putuint16(&query->slbuf, (isc_uint16_t) query->sendbuf.used); ISC_LIST_INIT(query->sendlist); ISC_LINK_INIT(&query->slbuf, link); - buffer = clone_buffer(&query->slbuf); - ISC_LIST_ENQUEUE(query->sendlist, buffer, link); - if (include_question) { - buffer = clone_buffer(&query->sendbuf); + if (!query->first_soa_rcvd) { + buffer = clone_buffer(&query->slbuf); ISC_LIST_ENQUEUE(query->sendlist, buffer, link); + if (include_question) { + buffer = clone_buffer(&query->sendbuf); + ISC_LIST_ENQUEUE(query->sendlist, buffer, link); + } } ISC_LINK_INIT(&query->lengthbuf, link); diff --git a/lib/dns/rdata/generic/isdn_20.c b/lib/dns/rdata/generic/isdn_20.c index feb9555031..d48d7a3849 100644 --- a/lib/dns/rdata/generic/isdn_20.c +++ b/lib/dns/rdata/generic/isdn_20.c @@ -127,7 +127,7 @@ fromstruct_isdn(ARGS_FROMSTRUCT) { RETERR(uint8_tobuffer(isdn->isdn_len, target)); RETERR(mem_tobuffer(target, isdn->isdn, isdn->isdn_len)); - if (isdn->subaddress == NULL && isdn->subaddress_len == 0) + if (isdn->subaddress == NULL) return (ISC_R_SUCCESS); RETERR(uint8_tobuffer(isdn->subaddress_len, target)); return (mem_tobuffer(target, isdn->subaddress, isdn->subaddress_len)); diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 6269e761ee..e11964b425 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -9279,6 +9279,7 @@ dns_zone_markdirty(dns_zone_t *zone) { if (inline_raw(zone)) { unsigned int soacount; secure = zone->secure; + INSIST(secure != zone); TRYLOCK_ZONE(result, secure); if (result != ISC_R_SUCCESS) { UNLOCK_ZONE(zone); @@ -13566,6 +13567,7 @@ dns_zone_replacedb(dns_zone_t *zone, dns_db_t *db, isc_boolean_t dump) { LOCK_ZONE(zone); if (inline_raw(zone)) { secure = zone->secure; + INSIST(secure != zone); TRYLOCK_ZONE(result, secure); if (result != ISC_R_SUCCESS) { UNLOCK_ZONE(zone); @@ -13826,6 +13828,7 @@ zone_xfrdone(dns_zone_t *zone, isc_result_t result) { LOCK_ZONE(zone); if (inline_raw(zone)) { secure = zone->secure; + INSIST(secure != zone); TRYLOCK_ZONE(result, secure); if (result != ISC_R_SUCCESS) { UNLOCK_ZONE(zone);