* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: dighost.c,v 1.333 2010/11/16 00:45:34 marka Exp $ */
+/* $Id: dighost.c,v 1.334 2010/11/16 05:38:30 marka Exp $ */
/*! \file
* \note
if (srv == NULL)
fatal("memory allocation failure in %s:%d",
__FILE__, __LINE__);
- strlcpy(srv->servername, servname, MXNAME);
- strlcpy(srv->userarg, userarg, MXNAME);
+ strncpy(srv->servername, servname, MXNAME);
+ strncpy(srv->userarg, userarg, MXNAME);
+ srv->servername[MXNAME-1] = 0;
+ srv->userarg[MXNAME-1] = 0;
ISC_LINK_INIT(srv, link);
return (srv);
}
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: host.c,v 1.123 2010/11/16 00:46:00 marka Exp $ */
+/* $Id: host.c,v 1.124 2010/11/16 05:38:30 marka Exp $ */
/*! \file */
if (isc_commandline_index >= argc)
show_usage();
- strlcpy(hostname, argv[isc_commandline_index], sizeof(hostname));
-
+ strncpy(hostname, argv[isc_commandline_index], sizeof(hostname));
+ hostname[sizeof(hostname)-1]=0;
if (argc > isc_commandline_index + 1) {
set_nameserver(argv[isc_commandline_index+1]);
debug("server is %s", argv[isc_commandline_index+1]);
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: nslookup.c,v 1.125 2010/11/16 00:46:39 marka Exp $ */
+/* $Id: nslookup.c,v 1.126 2010/11/16 05:38:31 marka Exp $ */
#include <config.h>
}
}
+static void
+safecpy(char *dest, char *src, int size) {
+ strncpy(dest, src, size);
+ dest[size-1] = 0;
+}
+
static void
set_port(const char *value) {
isc_uint32_t n;
show_settings(ISC_TRUE, ISC_FALSE);
} else if (strncasecmp(opt, "class=", 6) == 0) {
if (testclass(&opt[6]))
- strlcpy(defclass, &opt[6], sizeof(defclass));
+ safecpy(defclass, &opt[6], sizeof(defclass));
} else if (strncasecmp(opt, "cl=", 3) == 0) {
if (testclass(&opt[3]))
- strlcpy(defclass, &opt[3], sizeof(defclass));
+ safecpy(defclass, &opt[3], sizeof(defclass));
} else if (strncasecmp(opt, "type=", 5) == 0) {
if (testtype(&opt[5]))
- strlcpy(deftype, &opt[5], sizeof(deftype));
+ safecpy(deftype, &opt[5], sizeof(deftype));
} else if (strncasecmp(opt, "ty=", 3) == 0) {
if (testtype(&opt[3]))
- strlcpy(deftype, &opt[3], sizeof(deftype));
+ safecpy(deftype, &opt[3], sizeof(deftype));
} else if (strncasecmp(opt, "querytype=", 10) == 0) {
if (testtype(&opt[10]))
- strlcpy(deftype, &opt[10], sizeof(deftype));
+ safecpy(deftype, &opt[10], sizeof(deftype));
} else if (strncasecmp(opt, "query=", 6) == 0) {
if (testtype(&opt[6]))
- strlcpy(deftype, &opt[6], sizeof(deftype));
+ safecpy(deftype, &opt[6], sizeof(deftype));
} else if (strncasecmp(opt, "qu=", 3) == 0) {
if (testtype(&opt[3]))
- strlcpy(deftype, &opt[3], sizeof(deftype));
+ safecpy(deftype, &opt[3], sizeof(deftype));
} else if (strncasecmp(opt, "q=", 2) == 0) {
if (testtype(&opt[2]))
- strlcpy(deftype, &opt[2], sizeof(deftype));
+ safecpy(deftype, &opt[2], sizeof(deftype));
} else if (strncasecmp(opt, "domain=", 7) == 0) {
- strlcpy(domainopt, &opt[7], sizeof(domainopt));
+ safecpy(domainopt, &opt[7], sizeof(domainopt));
set_search_domain(domainopt);
usesearch = ISC_TRUE;
} else if (strncasecmp(opt, "do=", 3) == 0) {
- strlcpy(domainopt, &opt[3], sizeof(domainopt));
+ safecpy(domainopt, &opt[3], sizeof(domainopt));
set_search_domain(domainopt);
usesearch = ISC_TRUE;
} else if (strncasecmp(opt, "port=", 5) == 0) {
lookup = make_empty_lookup();
if (get_reverse(store, sizeof(store), opt, lookup->ip6_int, ISC_TRUE)
== ISC_R_SUCCESS) {
- strlcpy(lookup->textname, store, sizeof(lookup->textname));
+ safecpy(lookup->textname, store, sizeof(lookup->textname));
lookup->rdtype = dns_rdatatype_ptr;
lookup->rdtypeset = ISC_TRUE;
} else {
- strlcpy(lookup->textname, opt, sizeof(lookup->textname));
+ safecpy(lookup->textname, opt, sizeof(lookup->textname));
lookup->rdtype = rdtype;
lookup->rdtypeset = ISC_TRUE;
}
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: os.c,v 1.102 2010/11/16 00:47:48 marka Exp $ */
+/* $Id: os.c,v 1.103 2010/11/16 05:38:31 marka Exp $ */
/*! \file */
isc_buffer_availablelength(text),
"pid: %ld", (long)pid);
/* Only send a message if it is complete. */
- if (n > 0 && n < isc_buffer_availablelength(text))
+ if (n < isc_buffer_availablelength(text))
isc_buffer_add(text, n);
}
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: adb.c,v 1.250 2010/11/16 00:49:18 marka Exp $ */
+/* $Id: adb.c,v 1.251 2010/11/16 05:38:31 marka Exp $ */
/*! \file
*
*/
bucket = DNS_ADB_INVALIDBUCKET;
adbname = find_name_and_lock(adb, name, find->options, &bucket);
- INSIST(bucket != DNS_ADB_INVALIDBUCKET);
if (adb->name_sd[bucket]) {
DP(DEF_LEVEL,
"dns_adb_createfind: returning ISC_R_SHUTTINGDOWN");
result = ISC_R_SUCCESS;
bucket = DNS_ADB_INVALIDBUCKET;
entry = find_entry_and_lock(adb, sa, &bucket, now);
- INSIST(bucket != DNS_ADB_INVALIDBUCKET);
if (adb->entry_sd[bucket]) {
result = ISC_R_SHUTTINGDOWN;
goto unlock;
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: rcode.c,v 1.13 2010/11/16 00:53:36 marka Exp $ */
+/* $Id: rcode.c,v 1.14 2010/11/16 05:38:31 marka Exp $ */
#include <config.h>
#include <ctype.h>
isc_result_t result;
isc_buffer_t buf;
- if (size == 0U)
- return;
-
isc_buffer_init(&buf, array, size);
result = dns_rdataclass_totext(rdclass, &buf);
/*
else
result = ISC_R_NOSPACE;
}
- if (result != ISC_R_SUCCESS)
- strlcpy(array, "<unknown>", size);
+ if (result != ISC_R_SUCCESS) {
+ snprintf(array, size, "<unknown>");
+ array[size - 1] = '\0';
+ }
}
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: rdata.c,v 1.205 2010/11/16 00:53:36 marka Exp $ */
+/* $Id: rdata.c,v 1.206 2010/11/16 05:38:31 marka Exp $ */
/*! \file */
isc_result_t result;
isc_buffer_t buf;
- if (size == 0U)
- return;
-
isc_buffer_init(&buf, array, size);
result = dns_rdatatype_totext(rdtype, &buf);
/*
else
result = ISC_R_NOSPACE;
}
- if (result != ISC_R_SUCCESS)
- strlcpy(array, "<unknown>", size);
+ if (result != ISC_R_SUCCESS) {
+ snprintf(array, size, "<unknown>");
+ array[size - 1] = '\0';
+ }
}
/*
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: rdatalist.c,v 1.39 2010/11/16 00:50:28 marka Exp $ */
+/* $Id: rdatalist.c,v 1.40 2010/11/16 05:38:31 marka Exp $ */
/*! \file */
void
dns_rdatalist_init(dns_rdatalist_t *rdatalist) {
- REQUIRE(rdatalist != NULL);
-
/*
* Initialize rdatalist.
*/
isc__rdatalist_next(dns_rdataset_t *rdataset) {
dns_rdata_t *rdata;
- REQUIRE(rdataset != NULL);
-
rdata = rdataset->private2;
if (rdata == NULL)
return (ISC_R_NOMORE);
isc__rdatalist_current(dns_rdataset_t *rdataset, dns_rdata_t *rdata) {
dns_rdata_t *list_rdata;
- REQUIRE(rdataset != NULL);
-
list_rdata = rdataset->private2;
INSIST(list_rdata != NULL);
void
isc__rdatalist_clone(dns_rdataset_t *source, dns_rdataset_t *target) {
-
- REQUIRE(source != NULL);
- REQUIRE(target != NULL);
-
*target = *source;
/*
dns_rdata_t *rdata;
unsigned int count;
- REQUIRE(rdataset != NULL);
-
rdatalist = rdataset->private1;
count = 0;
dns_rdataset_t *rdset;
dns_ttl_t ttl;
- REQUIRE(rdataset != NULL);
-
for (rdset = ISC_LIST_HEAD(name->list);
rdset != NULL;
rdset = ISC_LIST_NEXT(rdset, link))
dns_rdataset_t *tnegsig = NULL;
dns_name_t *noqname = rdataset->private6;
- REQUIRE(rdataset != NULL);
REQUIRE((rdataset->attributes & DNS_RDATASETATTR_NOQNAME) != 0);
-
(void)dns_name_dynamic(noqname); /* Sanity Check. */
for (rdataset = ISC_LIST_HEAD(noqname->list);
dns_rdataset_t *rdset;
dns_ttl_t ttl;
- REQUIRE(rdataset != NULL);
-
for (rdset = ISC_LIST_HEAD(name->list);
rdset != NULL;
rdset = ISC_LIST_NEXT(rdset, link))
dns_rdataset_t *tnegsig = NULL;
dns_name_t *closest = rdataset->private7;
- REQUIRE(rdataset != NULL);
REQUIRE((rdataset->attributes & DNS_RDATASETATTR_CLOSEST) != 0);
-
(void)dns_name_dynamic(closest); /* Sanity Check. */
for (rdataset = ISC_LIST_HEAD(closest->list);
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: httpd.c,v 1.19 2010/11/16 00:51:41 marka Exp $ */
+/* $Id: httpd.c,v 1.20 2010/11/16 05:38:31 marka Exp $ */
/*! \file */
needlen += 3 + 1; /* room for response code, always 3 bytes */
needlen += strlen(httpd->retmsg) + 2; /* return msg + CRLF */
- while (isc_buffer_availablelength(&httpd->headerbuffer) < needlen) {
+ if (isc_buffer_availablelength(&httpd->headerbuffer) < needlen) {
result = grow_headerspace(httpd);
if (result != ISC_R_SUCCESS)
return (result);
needlen += 2 + strlen(val); /* :<space> and val */
needlen += 2; /* CRLF */
- while (isc_buffer_availablelength(&httpd->headerbuffer) < needlen) {
+ if (isc_buffer_availablelength(&httpd->headerbuffer) < needlen) {
result = grow_headerspace(httpd);
if (result != ISC_R_SUCCESS)
return (result);
{
isc_result_t result;
- while (isc_buffer_availablelength(&httpd->headerbuffer) < 2) {
+ if (isc_buffer_availablelength(&httpd->headerbuffer) < 2) {
result = grow_headerspace(httpd);
if (result != ISC_R_SUCCESS)
return (result);
needlen += 2 + strlen(buf); /* :<space> and val */
needlen += 2; /* CRLF */
- while (isc_buffer_availablelength(&httpd->headerbuffer) < needlen) {
+ if (isc_buffer_availablelength(&httpd->headerbuffer) < needlen) {
result = grow_headerspace(httpd);
if (result != ISC_R_SUCCESS)
return (result);
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: netaddr.c,v 1.39 2010/11/16 00:43:02 marka Exp $ */
+/* $Id: netaddr.c,v 1.40 2010/11/16 05:38:31 marka Exp $ */
/*! \file */
isc_buffer_init(&buf, array, size);
result = isc_netaddr_totext(na, &buf);
- if (size == 0)
- return;
-
/*
* Null terminate.
*/
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: sockaddr.c,v 1.71 2010/11/16 00:42:35 marka Exp $ */
+/* $Id: sockaddr.c,v 1.72 2010/11/16 05:38:31 marka Exp $ */
/*! \file */
isc_result_t result;
isc_buffer_t buf;
- if (size == 0U)
- return;
-
isc_buffer_init(&buf, array, size);
result = isc_sockaddr_totext(sa, &buf);
if (result != ISC_R_SUCCESS) {
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: parser.c,v 1.136 2010/11/16 00:41:32 marka Exp $ */
+/* $Id: parser.c,v 1.137 2010/11/16 05:38:31 marka Exp $ */
/*! \file */
void
cfg_obj_asnetprefix(const cfg_obj_t *obj, isc_netaddr_t *netaddr,
- unsigned int *prefixlen)
-{
+ unsigned int *prefixlen) {
REQUIRE(obj != NULL && obj->type->rep == &cfg_rep_netprefix);
- REQUIRE(netaddr != NULL);
- REQUIRE(prefixlen != NULL);
-
*netaddr = obj->value.netprefix.address;
*prefixlen = obj->value.netprefix.prefixlen;
}