+3388. [bug] Fixed several Coverity warnings. [RT #30996]
+
3387. [func] DS digest can be disabled at runtime with
disable-ds-digests. [RT #21581]
a->type == dns_rdatatype_a);
REQUIRE(aaaa == NULL || !dns_rdataset_isassociated(aaaa) ||
aaaa->type == dns_rdatatype_aaaa);
+
+ if (a == NULL || aaaa == NULL)
+ return (answer);
+
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
hints.ai_family = PF_UNSPEC;
}
return (ISC_TRUE);
}
- if (a == NULL || aaaa == NULL)
- return (answer);
+
/*
* Check that all glue records really exist.
*/
looknew = make_empty_lookup();
INSIST(looknew != NULL);
- strncpy(looknew->textname, lookold->textname, MXNAME);
+ strlcpy(looknew->textname, lookold->textname, MXNAME);
#if DIG_SIGCHASE_TD
- strncpy(looknew->textnamesigchase, lookold->textnamesigchase, MXNAME);
+ strlcpy(looknew->textnamesigchase, lookold->textnamesigchase, MXNAME);
#endif
- strncpy(looknew->cmdline, lookold->cmdline, MXNAME);
+ strlcpy(looknew->cmdline, lookold->cmdline, MXNAME);
looknew->textname[MXNAME-1] = 0;
looknew->rdtype = lookold->rdtype;
looknew->qrdtype = lookold->qrdtype;
len = strlen(hmac);
if (len >= (int) sizeof(buf))
fatal("unknown key type '%.*s'", len, hmac);
- strncpy(buf, hmac, sizeof(buf));
+ strlcpy(buf, hmac, sizeof(buf));
digestbits = 0;
secretstr = cfg_obj_asstring(secretobj);
algorithm = cfg_obj_asstring(algorithmobj);
- strncpy(keynametext, keyname, sizeof(keynametext));
- strncpy(keysecret, secretstr, sizeof(keysecret));
+ strlcpy(keynametext, keyname, sizeof(keynametext));
+ strlcpy(keysecret, secretstr, sizeof(keysecret));
parse_hmac(algorithm);
setup_text_key();
if (search == NULL)
fatal("memory allocation failure in %s:%d",
__FILE__, __LINE__);
- strncpy(search->origin, domain, MXNAME);
+ strlcpy(search->origin, domain, MXNAME);
search->origin[MXNAME-1] = 0;
ISC_LINK_INIT(search, link);
return (search);
= current_lookup->rdclassset;
current_lookup->rdclass = dns_rdataclass_in;
- strncpy(current_lookup->textnamesigchase,
+ strlcpy(current_lookup->textnamesigchase,
current_lookup->textname, MXNAME);
current_lookup->trace_root_sigchase = ISC_TRUE;
check_result(result, "dns_name_totext");
isc_buffer_usedregion(b, &r);
r.base[r.length] = '\0';
- strncpy(current_lookup->textname, (char*)r.base,
+ strlcpy(current_lookup->textname, (char*)r.base,
MXNAME);
isc_buffer_free(&b);
check_result(result, "dns_name_totext");
isc_buffer_usedregion(b, &r);
r.base[r.length] = '\0';
- strcpy(lookup->textname, (char*)r.base);
+ strlcpy(lookup->textname, (char*)r.base, sizeof(lookup->textname));
isc_buffer_free(&b);
if (type == dns_rdatatype_rrsig)
return (ISC_R_NOMEMORY);
memset(tempnamekey, 0, tempnamekeylen);
- strncpy(tempnamekey, tempname, tempnamelen);
+ strlcpy(tempnamekey, tempname, tempnamelen);
strcat(tempnamekey ,".key");
lookup->new_search = ISC_TRUE;
lookup->trace_root_sigchase = ISC_FALSE;
- strncpy(lookup->textname, lookup->textnamesigchase, MXNAME);
+ strlcpy(lookup->textname, lookup->textnamesigchase, MXNAME);
lookup->rdtype = lookup->rdtype_sigchase;
lookup->rdtypeset = ISC_TRUE;
dns_rdata_totext(&aaaa, &ns.name, b);
isc_buffer_usedregion(b, &r);
r.base[r.length] = '\0';
- strncpy(namestr, (char*)r.base,
+ strlcpy(namestr, (char*)r.base,
DNS_NAME_FORMATSIZE);
isc_buffer_free(&b);
dns_rdata_reset(&aaaa);
dns_rdata_totext(&a, &ns.name, b);
isc_buffer_usedregion(b, &r);
r.base[r.length] = '\0';
- strncpy(namestr, (char*)r.base,
+ strlcpy(namestr, (char*)r.base,
DNS_NAME_FORMATSIZE);
isc_buffer_free(&b);
dns_rdata_reset(&a);
{
isc_result_t result;
dns_rdata_t rdata = DNS_RDATA_INIT;
- dst_key_t *trustedKey = NULL;
dst_key_t *dnsseckey = NULL;
int i;
dst_key_free(&dnsseckey);
} while (dns_rdataset_next(rdataset) == ISC_R_SUCCESS);
- if (trustedKey != NULL)
- dst_key_free(&trustedKey);
- trustedKey = NULL;
-
return (ISC_R_NOTFOUND);
}
dns_rdata_nsec3_t nsec3;
dns_fixedname_t fname;
dns_name_t *hashname;
- unsigned char orig_salt[256];
+ unsigned char orig_salt[255];
size_t orig_saltlen;
dns_hash_t orig_hash;
isc_uint16_t orig_iter;
isc_result_t result;
isc_uint32_t ttl = ISC_UINT32_MAX;
+ dns_rdataset_init(&rdataset);
+
result = dns_db_getoriginnode(db, &node);
if (result != ISC_R_SUCCESS)
goto cleanup;
- dns_rdataset_init(&rdataset);
+
result = dns_db_findrdataset(db, node, version, dns_rdatatype_soa,
0, 0, &rdataset, NULL);
if (result != ISC_R_SUCCESS)
/* Parse parameters */
CHECK(zone_from_args(server, args, NULL, &zone, &zonename, ISC_TRUE));
- if (result != ISC_R_SUCCESS)
- return (result);
+
if (zone == NULL) {
result = ISC_R_UNEXPECTEDEND;
goto cleanup;
return (ISC_R_FAILURE);
}
- isc_mem_create(0, 0, &mctx);
+ result = isc_mem_create(0, 0, &mctx);
+ if (result != ISC_R_SUCCESS)
+ return (result);
cd = isc_mem_get(mctx, sizeof(*cd));
if (cd == NULL) {
INSIST(0);
}
- if (raw != NULL) {
+ if (raw != NULL && filename != NULL) {
#define SIGNED ".signed"
size_t signedlen = strlen(filename) + sizeof(SIGNED);
char *signedname;
*/
while ((tmpPtr = strrchr(tmpString,
cd->pathsep))
- != NULL) {
+ != NULL)
+ {
+ if ((strlen(host) +
+ strlen(tmpPtr + 1) + 2)
+ > ISC_DIR_NAMEMAX)
+ continue;
strcat(host, tmpPtr + 1);
strcat(host, ".");
tmpPtr[0] = '\0';
}
- strcat(host, tmpString);
+ if ((strlen(host) +
+ strlen(tmpString) + 1)
+ <= ISC_DIR_NAMEMAX)
+ strcat(host, tmpString);
}
foundHost = ISC_TRUE;
break;
case 2:
j++;
- if (allnodes == isc_boolean_true) {
+ if (allnodes)
host = isc_mem_strdup(ns_g_mctx,
vals[0]);
- } else {
+ else
strcpy(data, vals[0]);
- }
break;
case 3:
j++;
- if (allnodes == isc_boolean_true) {
+ if (allnodes)
strcpy(data, vals[0]);
- } else {
+ else {
strcat(data, " ");
strcat(data, vals[0]);
}
goto cleanup;
}
- if (allnodes == isc_boolean_true) {
+ if (allnodes && host != NULL) {
if (strcasecmp(host, "~") == 0)
result = dns_sdlz_putnamedrr(
(dns_sdlzallnodes_t *) ptr,
full_cleanup:
- destroy_sqldbinstance(dbi);
+ if (dbi != NULL)
+ destroy_sqldbinstance(dbi);
cleanup:
unsigned int attributes, unsigned int mask,
dns_dispatch_t **dispp)
{
- return dns_dispatch_getudp_dup(mgr, sockmgr, taskmgr, localaddr,
- buffersize, maxbuffers, maxrequests, buckets, increment,
- attributes, mask, dispp, NULL);
+ return (dns_dispatch_getudp_dup(mgr, sockmgr, taskmgr, localaddr,
+ buffersize, maxbuffers, maxrequests,
+ buckets, increment, attributes,
+ mask, dispp, NULL));
}
/*
typename);
exit(1);
}
- strcpy(ttn->typename, typename);
+ strncpy(ttn->typename, typename, TYPECLASSLEN);
ttn->type = type;
- strcpy(ttn->macroname, ttn->typename);
+ strncpy(ttn->macroname, ttn->typename, TYPECLASSLEN);
c = strlen(ttn->macroname);
while (c > 0) {
if (ttn->macroname[c - 1] == '-')
}
if (attr == NULL) {
- sprintf(tmp, "RRTYPE_%s_ATTRIBUTES", upper(ttn->macroname));
+ snprintf(tmp, sizeof(tmp),
+ "RRTYPE_%s_ATTRIBUTES", upper(ttn->macroname));
attr = tmp;
}
attr, typename);
exit(1);
}
- strcpy(ttn->attr, attr);
+ strncpy(ttn->attr, attr, sizeof(ttn->attr));
ttn->sorted = 0;
if (maxtype < type)
maxtype = type;
newtt->next = NULL;
newtt->rdclass = rdclass;
newtt->type = type;
- strcpy(newtt->classname, classname);
- strcpy(newtt->typename, typename);
+ strncpy(newtt->classname, classname, TYPECLASSLEN);
+ strncpy(newtt->typename, typename, TYPECLASSLEN);
if (strncmp(dirname, "./", 2) == 0)
dirname += 2;
- strcpy(newtt->dirname, dirname);
+ strncpy(newtt->dirname, dirname, 256);
tt = types;
oldtt = NULL;
newcc = (struct cc *)malloc(sizeof(*newcc));
newcc->rdclass = rdclass;
- strcpy(newcc->classname, classname);
+ strncpy(newcc->classname, classname, TYPECLASSLEN);
cc = classes;
oldcc = NULL;
if (!start_directory(dirname, &dir))
return;
- sprintf(fmt,"%s%c", "%20[-0-9a-z]_%d.", filetype);
+ snprintf(fmt, sizeof(fmt), "%s%c", "%20[-0-9a-z]_%d.", filetype);
while (next_file(&dir)) {
if (sscanf(dir.filename, fmt, typename, &type) != 2)
continue;
if ((type > 65535) || (type < 0))
continue;
- sprintf(buf, "%s_%d.%c", typename, type, filetype);
+ snprintf(buf, sizeof(buf),
+ "%s_%d.%c", typename, type, filetype);
if (strcmp(buf, dir.filename) != 0)
continue;
add(rdclass, classname, type, typename, dirname);
filetype = 'h';
break;
case 's':
- sprintf(srcdir, "%s/", isc_commandline_argument);
+ snprintf(srcdir, sizeof(srcdir),
+ "%s/", isc_commandline_argument);
break;
case 'F':
file = isc_commandline_argument;
exit(1);
}
- sprintf(buf, "%srdata", srcdir);
+ snprintf(buf, sizeof(buf), "%srdata", srcdir);
if (!start_directory(buf, &dir))
exit(1);
if ((rdclass > 65535) || (rdclass < 0))
continue;
- sprintf(buf, "%srdata/%s_%d", srcdir, classname, rdclass);
+ snprintf(buf, sizeof(buf),
+ "%srdata/%s_%d", srcdir, classname, rdclass);
if (strcmp(buf + 6 + strlen(srcdir), dir.filename) != 0)
continue;
sd(rdclass, classname, buf, filetype);
}
end_directory(&dir);
- sprintf(buf, "%srdata/generic", srcdir);
+ snprintf(buf, sizeof(buf), "%srdata/generic", srcdir);
sd(0, "", buf, filetype);
if (time(&now) != -1) {
if ((tm = localtime(&now)) != NULL && tm->tm_year > 104)
- sprintf(year, "-%d", tm->tm_year + 1900);
+ snprintf(year, sizeof(year), "-%d", tm->tm_year + 1900);
else
year[0] = 0;
} else
}
}
for (tt = types; tt != NULL; tt = tt->next) {
- sprintf(buf, "%s/%s_%d.h",
+ snprintf(buf, sizeof(buf), "%s/%s_%d.h",
tt->dirname, tt->typename, tt->type);
if ((fd = fopen(buf,"r")) != NULL) {
while (fgets(buf, sizeof(buf), fd) != NULL)
isc_result_t result;
res = fctx->res;
- unshared = ISC_TF((fctx->options | DNS_FETCHOPT_UNSHARED) != 0);
+ unshared = ISC_TF((fctx->options & DNS_FETCHOPT_UNSHARED) != 0);
/*
* If this name is a subdomain of the query domain, tell
* the ADB to start looking using zone/hint data. This keeps us
while (i < DNS_RPZ_CIDR_WORDS * 2 && w[i] == 0)
++i;
}
- if (len > (int)sizeof(str))
+ if (len >= (int)sizeof(str))
return (ISC_R_FAILURE);
}
}
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
- strncpy(addr.sun_path, path, sizeof(addr.sun_path));
+ strlcpy(addr.sun_path, path, sizeof(addr.sun_path));
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd == -1) {
setclosest = setnearest = ISC_FALSE;
optout = ISC_FALSE;
unknown = ISC_FALSE;
- (void)nsec3noexistnodata(val, val->event->name, name, rdataset,
- zonename, &exists, &data, &optout,
- &unknown, setclosestp, &setnearest,
- closestp, nearest);
- if (setclosest)
- proofs[DNS_VALIDATOR_CLOSESTENCLOSER] = name;
+ result = nsec3noexistnodata(val, val->event->name, name,
+ rdataset, zonename, &exists,
+ &data, &optout, &unknown,
+ setclosestp, &setnearest,
+ closestp, nearest);
if (unknown)
val->attributes |= VALATTR_FOUNDUNKNOWN;
if (result != ISC_R_SUCCESS)
continue;
+ if (setclosest)
+ proofs[DNS_VALIDATOR_CLOSESTENCLOSER] = name;
if (exists && !data && NEEDNODATA(val)) {
val->attributes |= VALATTR_FOUNDNODATA;
proofs[DNS_VALIDATOR_NODATAPROOF] = name;
isc_uint32_t start, end;
dns_zone_t *zone;
dns_db_t *db = NULL;
- dns_dbnode_t *node = NULL;
dns_dbversion_t *newver = NULL, *oldver = NULL;
dns_diff_t diff;
dns_difftuple_t *tuple = NULL, *soatuple = NULL;
dns_db_closeversion(db, &oldver, ISC_FALSE);
if (newver != NULL)
dns_db_closeversion(db, &newver, ISC_FALSE);
- if (node != NULL)
- dns_db_detachnode(db, &node);
dns_db_detach(&db);
}
if (rjournal != NULL)
}
}
- freeaddrinfo(res);
+ freeaddrinfo(res0);
}
int
isc_buffer_t source;
word = nsu_strsep(cmdlinep, " \t\r\n");
- if (*word == 0) {
+ if (word == NULL || *word == 0) {
fprintf(stderr, "could not read owner name\n");
exit(1);
}
}
INSIST(res->ai_addrlen <= sizeof(sa.type));
memcpy(&sa.type, res->ai_addr, res->ai_addrlen);
- freeaddrinfo(res);
sa.length = res->ai_addrlen;
+ freeaddrinfo(res);
ISC_LINK_INIT(&sa, link);
ISC_LIST_INIT(servers);
ISC_LIST_APPEND(servers, &sa, link);
#include <isc/lib.h>
#include <isc/mem.h>
#include <isc/sockaddr.h>
+#include <isc/string.h>
#include <isc/util.h>
#include <dns/client.h>
err = (net_order[i])(hostname, flags, &ai_list,
socktype, port);
if (err != 0) {
- if (ai_list != NULL)
+ if (ai_list != NULL) {
freeaddrinfo(ai_list);
+ ai_list = NULL;
+ }
break;
}
}
return (EAI_MEMORY);
slocal = SLOCAL(ai->ai_addr);
- strncpy(slocal->sun_path, name, sizeof(slocal->sun_path));
+ strlcpy(slocal->sun_path, name, sizeof(slocal->sun_path));
ai->ai_socktype = socktype;
/*
memset(&sname, 0, sizeof(sname));
sname.sun_family = AF_UNIX;
- strncpy(sname.sun_path, fname, sizeof(sname.sun_path));
- sname.sun_path[sizeof(sname.sun_path)-1] = '0';
+ strlcpy(sname.sun_path, fname, sizeof(sname.sun_path));
#ifdef ISC_PLATFORM_HAVESALEN
#if !defined(SUN_LEN)
#define SUN_LEN(su) \
{
char *dir, *file, *slash;
+ if (path == NULL)
+ return (ISC_R_INVALIDFILE);
+
slash = strrchr(path, '/');
if (slash == path) {
return (result);
_ctrl = isccc_alist_lookup(ack, "_ctrl");
- if (_ctrl == NULL)
- return (ISC_R_FAILURE);
+ if (_ctrl == NULL) {
+ result = ISC_R_FAILURE;
+ goto bad;
+ }
if (isccc_cc_definestring(ack, "_ack", (ok) ? "1" : "0") == NULL) {
result = ISC_R_NOMEMORY;
goto bad;
_ctrl = isccc_alist_lookup(message, "_ctrl");
_data = isccc_alist_lookup(message, "_data");
- if (_ctrl == NULL ||
- _data == NULL ||
+ if (_ctrl == NULL || _data == NULL ||
isccc_cc_lookupuint32(_ctrl, "_ser", &serial) != ISC_R_SUCCESS ||
isccc_cc_lookupstring(_data, "type", &type) != ISC_R_SUCCESS)
return (ISC_R_FAILURE);
&alist);
if (result != ISC_R_SUCCESS)
return (result);
+
_ctrl = isccc_alist_lookup(alist, "_ctrl");
- if (_ctrl == NULL)
- return (ISC_R_FAILURE);
+ if (_ctrl == NULL) {
+ result = ISC_R_FAILURE;
+ goto bad;
+ }
+
_data = isccc_alist_lookup(alist, "_data");
- if (_data == NULL)
- return (ISC_R_FAILURE);
+ if (_data == NULL) {
+ result = ISC_R_FAILURE;
+ goto bad;
+ }
+
if (isccc_cc_definestring(_ctrl, "_rpl", "1") == NULL ||
- isccc_cc_definestring(_data, "type", type) == NULL) {
- isccc_sexpr_free(&alist);
- return (ISC_R_NOMEMORY);
+ isccc_cc_definestring(_data, "type", type) == NULL)
+ {
+ result = ISC_R_NOMEMORY;
+ goto bad;
}
*alistp = alist;
return (ISC_R_SUCCESS);
+
+ bad:
+ isccc_sexpr_free(&alist);
+ return (result);
}
isccc_sexpr_t *
* Copy aliases.
*/
npp = he->h_aliases;
- cpp = (he1 != NULL) ? he1->h_aliases : he2->h_aliases;
+ cpp = (he1 != NULL) ? he1->h_aliases
+ : ((he2 != NULL) ? he2->h_aliases : NULL);
while (*cpp != NULL) {
len = strlen (*cpp) + 1;
*npp = malloc(len);