aboutsummaryrefslogtreecommitdiff
path: root/lib/isc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/isc')
-rw-r--r--lib/isc/api6
-rw-r--r--lib/isc/hash.c6
-rw-r--r--lib/isc/hmacmd5.c13
-rw-r--r--lib/isc/hmacsha.c65
-rw-r--r--lib/isc/httpd.c6
-rw-r--r--lib/isc/include/isc/platform.h.in5
-rw-r--r--lib/isc/include/isc/radix.h3
-rw-r--r--lib/isc/include/isc/ratelimiter.h12
-rw-r--r--lib/isc/md5.c8
-rw-r--r--lib/isc/mem.c35
-rw-r--r--lib/isc/radix.c3
-rw-r--r--lib/isc/ratelimiter.c48
-rw-r--r--lib/isc/result.c8
-rw-r--r--lib/isc/sha1.c8
-rw-r--r--lib/isc/sha2.c28
-rw-r--r--lib/isc/unix/app.c11
-rw-r--r--lib/isc/unix/include/isc/net.h28
-rw-r--r--lib/isc/unix/include/isc/time.h9
-rw-r--r--lib/isc/unix/net.c4
-rw-r--r--lib/isc/unix/socket.c9
-rw-r--r--lib/isc/unix/stdio.c10
-rw-r--r--lib/isc/unix/time.c5
22 files changed, 265 insertions, 65 deletions
diff --git a/lib/isc/api b/lib/isc/api
index d8990f0ffbea..38bb8eb7d795 100644
--- a/lib/isc/api
+++ b/lib/isc/api
@@ -4,6 +4,6 @@
# 9.8: 80-89, 120-129
# 9.9: 90-109
# 9.9-sub: 130-139
-LIBINTERFACE = 103
-LIBREVISION = 0
-LIBAGE = 8
+LIBINTERFACE = 104
+LIBREVISION = 2
+LIBAGE = 0
diff --git a/lib/isc/hash.c b/lib/isc/hash.c
index e12c47183f21..6ee8dcf5a1f7 100644
--- a/lib/isc/hash.c
+++ b/lib/isc/hash.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004-2007, 2009, 2013, 2014 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004-2007, 2009, 2013-2015 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -302,7 +302,6 @@ static void
destroy(isc_hash_t **hctxp) {
isc_hash_t *hctx;
isc_mem_t *mctx;
- unsigned char canary0[4], canary1[4];
REQUIRE(hctxp != NULL && *hctxp != NULL);
hctx = *hctxp;
@@ -324,10 +323,7 @@ destroy(isc_hash_t **hctxp) {
DESTROYLOCK(&hctx->lock);
- memmove(canary0, hctx + 1, sizeof(canary0));
memset(hctx, 0, sizeof(isc_hash_t));
- memmove(canary1, hctx + 1, sizeof(canary1));
- INSIST(memcmp(canary0, canary1, sizeof(canary0)) == 0);
isc_mem_put(mctx, hctx, sizeof(isc_hash_t));
isc_mem_detach(&mctx);
}
diff --git a/lib/isc/hmacmd5.c b/lib/isc/hmacmd5.c
index b26a336eadc0..9c10532c53c1 100644
--- a/lib/isc/hmacmd5.c
+++ b/lib/isc/hmacmd5.c
@@ -39,7 +39,12 @@ void
isc_hmacmd5_init(isc_hmacmd5_t *ctx, const unsigned char *key,
unsigned int len)
{
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Init(ctx, (const void *) key,
+ (int) len, EVP_md5()) == 1);
+#else
HMAC_Init(ctx, (const void *) key, (int) len, EVP_md5());
+#endif
}
void
@@ -51,12 +56,20 @@ void
isc_hmacmd5_update(isc_hmacmd5_t *ctx, const unsigned char *buf,
unsigned int len)
{
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Update(ctx, buf, (int) len) == 1);
+#else
HMAC_Update(ctx, buf, (int) len);
+#endif
}
void
isc_hmacmd5_sign(isc_hmacmd5_t *ctx, unsigned char *digest) {
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Final(ctx, digest, NULL) == 1);
+#else
HMAC_Final(ctx, digest, NULL);
+#endif
HMAC_CTX_cleanup(ctx);
}
diff --git a/lib/isc/hmacsha.c b/lib/isc/hmacsha.c
index ac2b70c59f6c..1f72330d35ce 100644
--- a/lib/isc/hmacsha.c
+++ b/lib/isc/hmacsha.c
@@ -40,7 +40,12 @@ void
isc_hmacsha1_init(isc_hmacsha1_t *ctx, const unsigned char *key,
unsigned int len)
{
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Init(ctx, (const void *) key,
+ (int) len, EVP_sha1()) == 1);
+#else
HMAC_Init(ctx, (const void *) key, (int) len, EVP_sha1());
+#endif
}
void
@@ -52,7 +57,11 @@ void
isc_hmacsha1_update(isc_hmacsha1_t *ctx, const unsigned char *buf,
unsigned int len)
{
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Update(ctx, buf, (int) len) == 1);
+#else
HMAC_Update(ctx, buf, (int) len);
+#endif
}
void
@@ -61,7 +70,11 @@ isc_hmacsha1_sign(isc_hmacsha1_t *ctx, unsigned char *digest, size_t len) {
REQUIRE(len <= ISC_SHA1_DIGESTLENGTH);
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Final(ctx, newdigest, NULL) == 1);
+#else
HMAC_Final(ctx, newdigest, NULL);
+#endif
HMAC_CTX_cleanup(ctx);
memmove(digest, newdigest, len);
memset(newdigest, 0, sizeof(newdigest));
@@ -71,7 +84,12 @@ void
isc_hmacsha224_init(isc_hmacsha224_t *ctx, const unsigned char *key,
unsigned int len)
{
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Init(ctx, (const void *) key,
+ (int) len, EVP_sha224()) == 1);
+#else
HMAC_Init(ctx, (const void *) key, (int) len, EVP_sha224());
+#endif
}
void
@@ -83,7 +101,11 @@ void
isc_hmacsha224_update(isc_hmacsha224_t *ctx, const unsigned char *buf,
unsigned int len)
{
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Update(ctx, buf, (int) len) == 1);
+#else
HMAC_Update(ctx, buf, (int) len);
+#endif
}
void
@@ -92,7 +114,11 @@ isc_hmacsha224_sign(isc_hmacsha224_t *ctx, unsigned char *digest, size_t len) {
REQUIRE(len <= ISC_SHA224_DIGESTLENGTH);
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Final(ctx, newdigest, NULL) == 1);
+#else
HMAC_Final(ctx, newdigest, NULL);
+#endif
HMAC_CTX_cleanup(ctx);
memmove(digest, newdigest, len);
memset(newdigest, 0, sizeof(newdigest));
@@ -102,7 +128,12 @@ void
isc_hmacsha256_init(isc_hmacsha256_t *ctx, const unsigned char *key,
unsigned int len)
{
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Init(ctx, (const void *) key,
+ (int) len, EVP_sha256()) == 1);
+#else
HMAC_Init(ctx, (const void *) key, (int) len, EVP_sha256());
+#endif
}
void
@@ -114,7 +145,11 @@ void
isc_hmacsha256_update(isc_hmacsha256_t *ctx, const unsigned char *buf,
unsigned int len)
{
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Update(ctx, buf, (int) len) == 1);
+#else
HMAC_Update(ctx, buf, (int) len);
+#endif
}
void
@@ -123,7 +158,11 @@ isc_hmacsha256_sign(isc_hmacsha256_t *ctx, unsigned char *digest, size_t len) {
REQUIRE(len <= ISC_SHA256_DIGESTLENGTH);
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Final(ctx, newdigest, NULL) == 1);
+#else
HMAC_Final(ctx, newdigest, NULL);
+#endif
HMAC_CTX_cleanup(ctx);
memmove(digest, newdigest, len);
memset(newdigest, 0, sizeof(newdigest));
@@ -133,7 +172,12 @@ void
isc_hmacsha384_init(isc_hmacsha384_t *ctx, const unsigned char *key,
unsigned int len)
{
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Init(ctx, (const void *) key,
+ (int) len, EVP_sha384()) == 1);
+#else
HMAC_Init(ctx, (const void *) key, (int) len, EVP_sha384());
+#endif
}
void
@@ -145,7 +189,11 @@ void
isc_hmacsha384_update(isc_hmacsha384_t *ctx, const unsigned char *buf,
unsigned int len)
{
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Update(ctx, buf, (int) len) == 1);
+#else
HMAC_Update(ctx, buf, (int) len);
+#endif
}
void
@@ -154,7 +202,11 @@ isc_hmacsha384_sign(isc_hmacsha384_t *ctx, unsigned char *digest, size_t len) {
REQUIRE(len <= ISC_SHA384_DIGESTLENGTH);
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Final(ctx, newdigest, NULL) == 1);
+#else
HMAC_Final(ctx, newdigest, NULL);
+#endif
HMAC_CTX_cleanup(ctx);
memmove(digest, newdigest, len);
memset(newdigest, 0, sizeof(newdigest));
@@ -164,7 +216,12 @@ void
isc_hmacsha512_init(isc_hmacsha512_t *ctx, const unsigned char *key,
unsigned int len)
{
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Init(ctx, (const void *) key,
+ (int) len, EVP_sha512()) == 1);
+#else
HMAC_Init(ctx, (const void *) key, (int) len, EVP_sha512());
+#endif
}
void
@@ -176,7 +233,11 @@ void
isc_hmacsha512_update(isc_hmacsha512_t *ctx, const unsigned char *buf,
unsigned int len)
{
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Update(ctx, buf, (int) len) == 1);
+#else
HMAC_Update(ctx, buf, (int) len);
+#endif
}
void
@@ -185,7 +246,11 @@ isc_hmacsha512_sign(isc_hmacsha512_t *ctx, unsigned char *digest, size_t len) {
REQUIRE(len <= ISC_SHA512_DIGESTLENGTH);
+#ifdef HMAC_RETURN_INT
+ RUNTIME_CHECK(HMAC_Final(ctx, newdigest, NULL) == 1);
+#else
HMAC_Final(ctx, newdigest, NULL);
+#endif
HMAC_CTX_cleanup(ctx);
memmove(digest, newdigest, len);
memset(newdigest, 0, sizeof(newdigest));
diff --git a/lib/isc/httpd.c b/lib/isc/httpd.c
index 46dab296f6a1..0c159f069df8 100644
--- a/lib/isc/httpd.c
+++ b/lib/isc/httpd.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2008, 2010-2012, 2014 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2006-2008, 2010-2012, 2014, 2015 Internet Systems Consortium, Inc. ("ISC")
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -648,7 +648,7 @@ isc_httpd_recvdone(isc_task_t *task, isc_event_t *ev) {
isc_socketevent_t *sev = (isc_socketevent_t *)ev;
isc_httpdurl_t *url;
isc_time_t now;
- char datebuf[32]; /* Only need 30, but safety first */
+ char datebuf[ISC_FORMATHTTPTIMESTAMP_SIZE];
ENTER("recv");
@@ -729,7 +729,7 @@ isc_httpd_recvdone(isc_task_t *task, isc_event_t *ev) {
isc_httpd_addheader(httpd, "Expires", datebuf);
if (url != NULL && url->isstatic) {
- char loadbuf[32];
+ char loadbuf[ISC_FORMATHTTPTIMESTAMP_SIZE];
isc_time_formathttptimestamp(&url->loadtime,
loadbuf, sizeof(loadbuf));
isc_httpd_addheader(httpd, "Last-Modified", loadbuf);
diff --git a/lib/isc/include/isc/platform.h.in b/lib/isc/include/isc/platform.h.in
index 07553e36b898..69f81e0af11a 100644
--- a/lib/isc/include/isc/platform.h.in
+++ b/lib/isc/include/isc/platform.h.in
@@ -132,6 +132,11 @@
@ISC_PLATFORM_FIXIN6ISADDR@
/*! \brief
+ * Define if the system has struct sockaddr_storage.
+ */
+@ISC_PLATFORM_HAVESOCKADDRSTORAGE@
+
+/*! \brief
* Define if the system supports kqueue multiplexing
*/
@ISC_PLATFORM_HAVEKQUEUE@
diff --git a/lib/isc/include/isc/radix.h b/lib/isc/include/isc/radix.h
index 1c1887f1d0c0..f6e50aa650b1 100644
--- a/lib/isc/include/isc/radix.h
+++ b/lib/isc/include/isc/radix.h
@@ -36,8 +36,9 @@
#define NETADDR_TO_PREFIX_T(na,pt,bits) \
do { \
+ const void *p = na; \
memset(&(pt), 0, sizeof(pt)); \
- if((na) != NULL) { \
+ if (p != NULL) { \
(pt).family = (na)->family; \
(pt).bitlen = (bits); \
if ((pt).family == AF_INET6) { \
diff --git a/lib/isc/include/isc/ratelimiter.h b/lib/isc/include/isc/ratelimiter.h
index 00a7209758bb..288b8ef28a38 100644
--- a/lib/isc/include/isc/ratelimiter.h
+++ b/lib/isc/include/isc/ratelimiter.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004-2007, 2009, 2014 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2002 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -89,6 +89,16 @@ isc_ratelimiter_enqueue(isc_ratelimiter_t *rl, isc_task_t *task,
*\li '(*eventp)->ev_sender' to be NULL.
*/
+isc_result_t
+isc_ratelimiter_dequeue(isc_ratelimiter_t *rl, isc_event_t *event);
+/*
+ * Dequeue a event off the ratelimiter queue.
+ *
+ * Returns:
+ * \li ISC_R_NOTFOUND if the event is no longer linked to the rate limiter.
+ * \li ISC_R_SUCCESS
+ */
+
void
isc_ratelimiter_shutdown(isc_ratelimiter_t *ratelimiter);
/*%<
diff --git a/lib/isc/md5.c b/lib/isc/md5.c
index 5d212502938b..579d61c20b2a 100644
--- a/lib/isc/md5.c
+++ b/lib/isc/md5.c
@@ -47,7 +47,7 @@
void
isc_md5_init(isc_md5_t *ctx) {
- EVP_DigestInit(ctx, EVP_md5());
+ RUNTIME_CHECK(EVP_DigestInit(ctx, EVP_md5()) == 1);
}
void
@@ -57,12 +57,14 @@ isc_md5_invalidate(isc_md5_t *ctx) {
void
isc_md5_update(isc_md5_t *ctx, const unsigned char *buf, unsigned int len) {
- EVP_DigestUpdate(ctx, (const void *) buf, (size_t) len);
+ RUNTIME_CHECK(EVP_DigestUpdate(ctx,
+ (const void *) buf,
+ (size_t) len) == 1);
}
void
isc_md5_final(isc_md5_t *ctx, unsigned char *digest) {
- EVP_DigestFinal(ctx, digest, NULL);
+ RUNTIME_CHECK(EVP_DigestFinal(ctx, digest, NULL) == 1);
}
#else
diff --git a/lib/isc/mem.c b/lib/isc/mem.c
index 043a579077fa..1962245c01c8 100644
--- a/lib/isc/mem.c
+++ b/lib/isc/mem.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004-2010, 2012-2014 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004-2010, 2012-2015 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1997-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -15,8 +15,6 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id$ */
-
/*! \file */
#include <config.h>
@@ -115,7 +113,8 @@ typedef ISC_LIST(debuglink_t) debuglist_t;
static ISC_LIST(isc__mem_t) contexts;
static isc_once_t once = ISC_ONCE_INIT;
-static isc_mutex_t lock;
+static isc_mutex_t contextslock;
+static isc_mutex_t createlock;
/*%
* Total size of lost memory due to a bug of external library.
@@ -751,9 +750,8 @@ mem_putunlocked(isc__mem_t *ctx, void *mem, size_t size) {
(ctx->memfree)(ctx->arg, mem);
INSIST(ctx->stats[ctx->max_size].gets != 0U);
ctx->stats[ctx->max_size].gets--;
- INSIST(size <= ctx->total);
+ INSIST(size <= ctx->inuse);
ctx->inuse -= size;
- ctx->total -= size;
return;
}
@@ -882,7 +880,8 @@ default_memfree(void *arg, void *ptr) {
static void
initialize_action(void) {
- RUNTIME_CHECK(isc_mutex_init(&lock) == ISC_R_SUCCESS);
+ RUNTIME_CHECK(isc_mutex_init(&createlock) == ISC_R_SUCCESS);
+ RUNTIME_CHECK(isc_mutex_init(&contextslock) == ISC_R_SUCCESS);
ISC_LIST_INIT(contexts);
totallost = 0;
}
@@ -1010,9 +1009,9 @@ isc__mem_createx2(size_t init_max_size, size_t target_size,
ctx->memalloc_failures = 0;
- LOCK(&lock);
+ LOCK(&contextslock);
ISC_LIST_INITANDAPPEND(contexts, ctx, link);
- UNLOCK(&lock);
+ UNLOCK(&contextslock);
*ctxp = (isc_mem_t *)ctx;
return (ISC_R_SUCCESS);
@@ -1056,10 +1055,10 @@ destroy(isc__mem_t *ctx) {
unsigned int i;
isc_ondestroy_t ondest;
- LOCK(&lock);
+ LOCK(&contextslock);
ISC_LIST_UNLINK(contexts, ctx, link);
totallost += ctx->inuse;
- UNLOCK(&lock);
+ UNLOCK(&contextslock);
ctx->common.impmagic = 0;
ctx->common.magic = 0;
@@ -2287,14 +2286,14 @@ isc__mem_printallactive(FILE *file) {
RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS);
- LOCK(&lock);
+ LOCK(&contextslock);
for (ctx = ISC_LIST_HEAD(contexts);
ctx != NULL;
ctx = ISC_LIST_NEXT(ctx, link)) {
fprintf(file, "context: %p\n", ctx);
print_active(ctx, file);
}
- UNLOCK(&lock);
+ UNLOCK(&contextslock);
#endif
}
@@ -2306,7 +2305,7 @@ isc__mem_checkdestroyed(FILE *file) {
RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS);
- LOCK(&lock);
+ LOCK(&contextslock);
if (!ISC_LIST_EMPTY(contexts)) {
#if ISC_MEM_TRACKLINES
isc__mem_t *ctx;
@@ -2321,7 +2320,7 @@ isc__mem_checkdestroyed(FILE *file) {
#endif
INSIST(0);
}
- UNLOCK(&lock);
+ UNLOCK(&contextslock);
}
ISC_MEMFUNC_SCOPE unsigned int
@@ -2455,18 +2454,18 @@ isc_mem_renderxml(xmlTextWriterPtr writer) {
RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS);
- LOCK(&lock);
+ LOCK(&contextslock);
lost = totallost;
for (ctx = ISC_LIST_HEAD(contexts);
ctx != NULL;
ctx = ISC_LIST_NEXT(ctx, link)) {
xmlrc = renderctx(ctx, &summary, writer);
if (xmlrc < 0) {
- UNLOCK(&lock);
+ UNLOCK(&contextslock);
goto error;
}
}
- UNLOCK(&lock);
+ UNLOCK(&contextslock);
TRY0(xmlTextWriterEndElement(writer)); /* contexts */
diff --git a/lib/isc/radix.c b/lib/isc/radix.c
index df26615fa9bf..1367def320ee 100644
--- a/lib/isc/radix.c
+++ b/lib/isc/radix.c
@@ -279,6 +279,9 @@ isc_radix_search(isc_radix_tree_t *radix, isc_radix_node_t **target,
while (cnt-- > 0) {
node = stack[cnt];
+ if (prefix->bitlen < node->bit)
+ continue;
+
if (_comp_with_mask(isc_prefix_tochar(node->prefix),
isc_prefix_tochar(prefix),
node->prefix->bitlen)) {
diff --git a/lib/isc/ratelimiter.c b/lib/isc/ratelimiter.c
index fc66e9f61efb..96571e1ca471 100644
--- a/lib/isc/ratelimiter.c
+++ b/lib/isc/ratelimiter.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2005, 2007, 2012 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004, 2005, 2007, 2012, 2014, 2015 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2002 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -79,6 +79,7 @@ isc_ratelimiter_create(isc_mem_t *mctx, isc_timermgr_t *timermgr,
result = isc_mutex_init(&rl->lock);
if (result != ISC_R_SUCCESS)
goto free_mem;
+
result = isc_timer_create(timermgr, isc_timertype_inactive,
NULL, NULL, rl->task, ratelimiter_tick,
rl, &rl->timer);
@@ -109,6 +110,10 @@ free_mem:
isc_result_t
isc_ratelimiter_setinterval(isc_ratelimiter_t *rl, isc_interval_t *interval) {
isc_result_t result = ISC_R_SUCCESS;
+
+ REQUIRE(rl != NULL);
+ REQUIRE(interval != NULL);
+
LOCK(&rl->lock);
rl->interval = *interval;
/*
@@ -124,6 +129,9 @@ isc_ratelimiter_setinterval(isc_ratelimiter_t *rl, isc_interval_t *interval) {
void
isc_ratelimiter_setpertic(isc_ratelimiter_t *rl, isc_uint32_t pertic) {
+
+ REQUIRE(rl != NULL);
+
if (pertic == 0)
pertic = 1;
rl->pertic = pertic;
@@ -136,18 +144,18 @@ isc_ratelimiter_enqueue(isc_ratelimiter_t *rl, isc_task_t *task,
isc_result_t result = ISC_R_SUCCESS;
isc_event_t *ev;
- REQUIRE(eventp != NULL && *eventp != NULL);
+ REQUIRE(rl != NULL);
REQUIRE(task != NULL);
+ REQUIRE(eventp != NULL && *eventp != NULL);
ev = *eventp;
REQUIRE(ev->ev_sender == NULL);
LOCK(&rl->lock);
if (rl->state == isc_ratelimiter_ratelimited ||
rl->state == isc_ratelimiter_stalled) {
- isc_event_t *ev = *eventp;
ev->ev_sender = task;
- ISC_LIST_APPEND(rl->pending, ev, ev_link);
*eventp = NULL;
+ ISC_LIST_APPEND(rl->pending, ev, ev_link);
} else if (rl->state == isc_ratelimiter_idle) {
result = isc_timer_reset(rl->timer, isc_timertype_ticker, NULL,
&rl->interval, ISC_FALSE);
@@ -165,6 +173,23 @@ isc_ratelimiter_enqueue(isc_ratelimiter_t *rl, isc_task_t *task,
return (result);
}
+isc_result_t
+isc_ratelimiter_dequeue(isc_ratelimiter_t *rl, isc_event_t *event) {
+ isc_result_t result = ISC_R_SUCCESS;
+
+ REQUIRE(rl != NULL);
+ REQUIRE(event != NULL);
+
+ LOCK(&rl->lock);
+ if (ISC_LINK_LINKED(event, ev_link)) {
+ ISC_LIST_UNLINK(rl->pending, event, ev_link);
+ event->ev_sender = NULL;
+ } else
+ result = ISC_R_NOTFOUND;
+ UNLOCK(&rl->lock);
+ return (result);
+}
+
static void
ratelimiter_tick(isc_task_t *task, isc_event_t *event) {
isc_result_t result = ISC_R_SUCCESS;
@@ -211,6 +236,9 @@ void
isc_ratelimiter_shutdown(isc_ratelimiter_t *rl) {
isc_event_t *ev;
isc_task_t *task;
+
+ REQUIRE(rl != NULL);
+
LOCK(&rl->lock);
rl->state = isc_ratelimiter_shuttingdown;
(void)isc_timer_reset(rl->timer, isc_timertype_inactive,
@@ -222,6 +250,7 @@ isc_ratelimiter_shutdown(isc_ratelimiter_t *rl) {
isc_task_send(task, &ev);
}
isc_timer_detach(&rl->timer);
+
/*
* Send an event to our task. The delivery of this event
* indicates that no more timer events will be delivered.
@@ -249,6 +278,7 @@ ratelimiter_free(isc_ratelimiter_t *rl) {
void
isc_ratelimiter_attach(isc_ratelimiter_t *source, isc_ratelimiter_t **target) {
+
REQUIRE(source != NULL);
REQUIRE(target != NULL && *target == NULL);
@@ -262,9 +292,13 @@ isc_ratelimiter_attach(isc_ratelimiter_t *source, isc_ratelimiter_t **target) {
void
isc_ratelimiter_detach(isc_ratelimiter_t **rlp) {
- isc_ratelimiter_t *rl = *rlp;
+ isc_ratelimiter_t *rl;
isc_boolean_t free_now = ISC_FALSE;
+ REQUIRE(rlp != NULL && *rlp != NULL);
+
+ rl = *rlp;
+
LOCK(&rl->lock);
REQUIRE(rl->refs > 0);
rl->refs--;
@@ -282,6 +316,8 @@ isc_result_t
isc_ratelimiter_stall(isc_ratelimiter_t *rl) {
isc_result_t result = ISC_R_SUCCESS;
+ REQUIRE(rl != NULL);
+
LOCK(&rl->lock);
switch (rl->state) {
case isc_ratelimiter_shuttingdown:
@@ -305,6 +341,8 @@ isc_result_t
isc_ratelimiter_release(isc_ratelimiter_t *rl) {
isc_result_t result = ISC_R_SUCCESS;
+ REQUIRE(rl != NULL);
+
LOCK(&rl->lock);
switch (rl->state) {
case isc_ratelimiter_shuttingdown:
diff --git a/lib/isc/result.c b/lib/isc/result.c
index 2bd2fb4218ed..6cbd8b4722a1 100644
--- a/lib/isc/result.c
+++ b/lib/isc/result.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2005, 2007, 2008, 2012, 2014 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004, 2005, 2007, 2008, 2012, 2014, 2015 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1998-2001, 2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -40,7 +40,7 @@ typedef struct resulttable {
ISC_LINK(struct resulttable) link;
} resulttable;
-static const char *text[ISC_R_NRESULTS] = {
+static const char *description[ISC_R_NRESULTS] = {
"success", /*%< 0 */
"out of memory", /*%< 1 */
"timed out", /*%< 2 */
@@ -153,8 +153,8 @@ initialize_action(void) {
RUNTIME_CHECK(isc_mutex_init(&lock) == ISC_R_SUCCESS);
ISC_LIST_INIT(tables);
- result = register_table(ISC_RESULTCLASS_ISC, ISC_R_NRESULTS, text,
- isc_msgcat, ISC_RESULT_RESULTSET);
+ result = register_table(ISC_RESULTCLASS_ISC, ISC_R_NRESULTS,
+ description, isc_msgcat, ISC_RESULT_RESULTSET);
if (result != ISC_R_SUCCESS)
UNEXPECTED_ERROR(__FILE__, __LINE__,
"register_table() %s: %u",
diff --git a/lib/isc/sha1.c b/lib/isc/sha1.c
index aca90b43830a..3d64994b2a73 100644
--- a/lib/isc/sha1.c
+++ b/lib/isc/sha1.c
@@ -51,7 +51,7 @@ isc_sha1_init(isc_sha1_t *context)
{
INSIST(context != NULL);
- EVP_DigestInit(context, EVP_sha1());
+ RUNTIME_CHECK(EVP_DigestInit(context, EVP_sha1()) == 1);
}
void
@@ -66,7 +66,9 @@ isc_sha1_update(isc_sha1_t *context, const unsigned char *data,
INSIST(context != 0);
INSIST(data != 0);
- EVP_DigestUpdate(context, (const void *) data, (size_t) len);
+ RUNTIME_CHECK(EVP_DigestUpdate(context,
+ (const void *) data,
+ (size_t) len) == 1);
}
void
@@ -74,7 +76,7 @@ isc_sha1_final(isc_sha1_t *context, unsigned char *digest) {
INSIST(digest != 0);
INSIST(context != 0);
- EVP_DigestFinal(context, digest, NULL);
+ RUNTIME_CHECK(EVP_DigestFinal(context, digest, NULL) == 1);
}
#else
diff --git a/lib/isc/sha2.c b/lib/isc/sha2.c
index a61ea99c2ace..7e21a397e76f 100644
--- a/lib/isc/sha2.c
+++ b/lib/isc/sha2.c
@@ -70,7 +70,7 @@ isc_sha224_init(isc_sha224_t *context) {
if (context == (isc_sha224_t *)0) {
return;
}
- EVP_DigestInit(context, EVP_sha224());
+ RUNTIME_CHECK(EVP_DigestInit(context, EVP_sha224()) == 1);
}
void
@@ -88,7 +88,8 @@ isc_sha224_update(isc_sha224_t *context, const isc_uint8_t* data, size_t len) {
/* Sanity check: */
REQUIRE(context != (isc_sha224_t *)0 && data != (isc_uint8_t*)0);
- EVP_DigestUpdate(context, (const void *) data, len);
+ RUNTIME_CHECK(EVP_DigestUpdate(context,
+ (const void *) data, len) == 1);
}
void
@@ -98,7 +99,7 @@ isc_sha224_final(isc_uint8_t digest[], isc_sha224_t *context) {
/* If no digest buffer is passed, we don't bother doing this: */
if (digest != (isc_uint8_t*)0) {
- EVP_DigestFinal(context, digest, NULL);
+ RUNTIME_CHECK(EVP_DigestFinal(context, digest, NULL) == 1);
} else {
EVP_MD_CTX_cleanup(context);
}
@@ -109,7 +110,7 @@ isc_sha256_init(isc_sha256_t *context) {
if (context == (isc_sha256_t *)0) {
return;
}
- EVP_DigestInit(context, EVP_sha256());
+ RUNTIME_CHECK(EVP_DigestInit(context, EVP_sha256()) == 1);
}
void
@@ -127,7 +128,8 @@ isc_sha256_update(isc_sha256_t *context, const isc_uint8_t *data, size_t len) {
/* Sanity check: */
REQUIRE(context != (isc_sha256_t *)0 && data != (isc_uint8_t*)0);
- EVP_DigestUpdate(context, (const void *) data, len);
+ RUNTIME_CHECK(EVP_DigestUpdate(context,
+ (const void *) data, len) == 1);
}
void
@@ -137,7 +139,7 @@ isc_sha256_final(isc_uint8_t digest[], isc_sha256_t *context) {
/* If no digest buffer is passed, we don't bother doing this: */
if (digest != (isc_uint8_t*)0) {
- EVP_DigestFinal(context, digest, NULL);
+ RUNTIME_CHECK(EVP_DigestFinal(context, digest, NULL) == 1);
} else {
EVP_MD_CTX_cleanup(context);
}
@@ -148,7 +150,7 @@ isc_sha512_init(isc_sha512_t *context) {
if (context == (isc_sha512_t *)0) {
return;
}
- EVP_DigestInit(context, EVP_sha512());
+ RUNTIME_CHECK(EVP_DigestInit(context, EVP_sha512()) == 1);
}
void
@@ -165,7 +167,8 @@ void isc_sha512_update(isc_sha512_t *context, const isc_uint8_t *data, size_t le
/* Sanity check: */
REQUIRE(context != (isc_sha512_t *)0 && data != (isc_uint8_t*)0);
- EVP_DigestUpdate(context, (const void *) data, len);
+ RUNTIME_CHECK(EVP_DigestUpdate(context,
+ (const void *) data, len) == 1);
}
void isc_sha512_final(isc_uint8_t digest[], isc_sha512_t *context) {
@@ -174,7 +177,7 @@ void isc_sha512_final(isc_uint8_t digest[], isc_sha512_t *context) {
/* If no digest buffer is passed, we don't bother doing this: */
if (digest != (isc_uint8_t*)0) {
- EVP_DigestFinal(context, digest, NULL);
+ RUNTIME_CHECK(EVP_DigestFinal(context, digest, NULL) == 1);
} else {
EVP_MD_CTX_cleanup(context);
}
@@ -185,7 +188,7 @@ isc_sha384_init(isc_sha384_t *context) {
if (context == (isc_sha384_t *)0) {
return;
}
- EVP_DigestInit(context, EVP_sha384());
+ RUNTIME_CHECK(EVP_DigestInit(context, EVP_sha384()) == 1);
}
void
@@ -203,7 +206,8 @@ isc_sha384_update(isc_sha384_t *context, const isc_uint8_t* data, size_t len) {
/* Sanity check: */
REQUIRE(context != (isc_sha512_t *)0 && data != (isc_uint8_t*)0);
- EVP_DigestUpdate(context, (const void *) data, len);
+ RUNTIME_CHECK(EVP_DigestUpdate(context,
+ (const void *) data, len) == 1);
}
void
@@ -213,7 +217,7 @@ isc_sha384_final(isc_uint8_t digest[], isc_sha384_t *context) {
/* If no digest buffer is passed, we don't bother doing this: */
if (digest != (isc_uint8_t*)0) {
- EVP_DigestFinal(context, digest, NULL);
+ RUNTIME_CHECK(EVP_DigestFinal(context, digest, NULL) == 1);
} else {
EVP_MD_CTX_cleanup(context);
}
diff --git a/lib/isc/unix/app.c b/lib/isc/unix/app.c
index 6c53559fb032..aeebc31f9a43 100644
--- a/lib/isc/unix/app.c
+++ b/lib/isc/unix/app.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2005, 2007-2009, 2013, 2014 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004, 2005, 2007-2009, 2013-2015 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -692,6 +692,15 @@ isc__app_ctxrun(isc_appctx_t *ctx0) {
strbuf);
return (ISC_R_UNEXPECTED);
}
+#ifdef HAVE_GPERFTOOLS_PROFILER
+ if (sigaddset(&sset, SIGALRM) != 0) {
+ isc__strerror(errno, strbuf, sizeof(strbuf));
+ UNEXPECTED_ERROR(__FILE__, __LINE__,
+ "isc_app_run() sigsetops: %s",
+ strbuf);
+ return (ISC_R_UNEXPECTED);
+ }
+#endif
result = sigsuspend(&sset);
#endif /* HAVE_SIGWAIT */
diff --git a/lib/isc/unix/include/isc/net.h b/lib/isc/unix/include/isc/net.h
index c9ceaf774e89..e3058a024bba 100644
--- a/lib/isc/unix/include/isc/net.h
+++ b/lib/isc/unix/include/isc/net.h
@@ -37,6 +37,7 @@
*\li struct sockaddr
*\li struct sockaddr_in
*\li struct sockaddr_in6
+ *\li struct sockaddr_storage
*\li in_port_t
*
* It ensures that the AF_ and PF_ macros are defined.
@@ -187,6 +188,33 @@ struct in6_pktinfo {
};
#endif
+
+#ifndef ISC_PLATFORM_HAVESOCKADDRSTORAGE
+#define _SS_MAXSIZE 128
+#define _SS_ALIGNSIZE (sizeof (isc_uint64_t))
+#ifdef ISC_PLATFORM_HAVESALEN
+#define _SS_PAD1SIZE (_SS_ALIGNSIZE - (2 * sizeof(isc_uint8_t)))
+#define _SS_PAD2SIZE (_SS_MAXSIZE - (_SS_ALIGNSIZE + _SS_PAD1SIZE \
+ + 2 * sizeof(isc_uint8_t)))
+#else
+#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(isc_uint16_t))
+#define _SS_PAD2SIZE (_SS_MAXSIZE - (_SS_ALIGNSIZE + _SS_PAD1SIZE \
+ + sizeof(isc_uint16_t)))
+#endif
+
+struct sockaddr_storage {
+#ifdef ISC_PLATFORM_HAVESALEN
+ isc_uint8_t ss_len;
+ isc_uint8_t ss_family;
+#else
+ isc_uint16_t ss_family;
+#endif
+ char __ss_pad1[_SS_PAD1SIZE];
+ isc_uint64_t __ss_align; /* field to force desired structure */
+ char __ss_pad2[_SS_PAD2SIZE];
+};
+#endif
+
#if defined(ISC_PLATFORM_HAVEIPV6) && defined(ISC_PLATFORM_NEEDIN6ADDRANY)
extern const struct in6_addr isc_net_in6addrany;
/*%
diff --git a/lib/isc/unix/include/isc/time.h b/lib/isc/unix/include/isc/time.h
index 2a83f099305f..fd767040aeca 100644
--- a/lib/isc/unix/include/isc/time.h
+++ b/lib/isc/unix/include/isc/time.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004-2009, 2012, 2014 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004-2009, 2012, 2014, 2015 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1998-2001 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -43,6 +43,13 @@ struct isc_interval {
extern const isc_interval_t * const isc_interval_zero;
+/*
+ * ISC_FORMATHTTPTIMESTAMP_SIZE needs to be 30 in C locale and potentially
+ * more for other locales to handle longer national abbreviations when
+ * expanding strftime's %a and %b.
+ */
+#define ISC_FORMATHTTPTIMESTAMP_SIZE 50
+
ISC_LANG_BEGINDECLS
void
diff --git a/lib/isc/unix/net.c b/lib/isc/unix/net.c
index 1fedbc438ded..e4de0489ec11 100644
--- a/lib/isc/unix/net.c
+++ b/lib/isc/unix/net.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2005, 2007, 2008, 2012 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004, 2005, 2007, 2008, 2012, 2014 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -317,6 +317,7 @@ initialize_ipv6only(void) {
#endif /* WANT_IPV6 */
#ifdef ISC_PLATFORM_HAVEIN6PKTINFO
+#ifdef WANT_IPV6
static void
try_ipv6pktinfo(void) {
int s, on;
@@ -368,6 +369,7 @@ initialize_ipv6pktinfo(void) {
RUNTIME_CHECK(isc_once_do(&once_ipv6pktinfo,
try_ipv6pktinfo) == ISC_R_SUCCESS);
}
+#endif /* WANT_IPV6 */
#endif /* ISC_PLATFORM_HAVEIN6PKTINFO */
#endif /* ISC_PLATFORM_HAVEIPV6 */
diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c
index 2a004234d429..110eafe50fd1 100644
--- a/lib/isc/unix/socket.c
+++ b/lib/isc/unix/socket.c
@@ -1763,7 +1763,7 @@ doio_recv(isc__socket_t *sock, isc_socketevent_t *dev) {
}
/*
* Simulate a firewall blocking UDP responses bigger than
- * 512 bytes.
+ * 'maxudp' bytes.
*/
if (sock->manager->maxudp != 0 && cc > sock->manager->maxudp)
return (DOIO_SOFT);
@@ -1857,7 +1857,12 @@ doio_send(isc__socket_t *sock, isc_socketevent_t *dev) {
build_msghdr_send(sock, dev, &msghdr, iov, &write_count);
resend:
- cc = sendmsg(sock->fd, &msghdr, 0);
+ if (sock->type == isc_sockettype_udp &&
+ sock->manager->maxudp != 0 &&
+ write_count > (size_t)sock->manager->maxudp)
+ cc = write_count;
+ else
+ cc = sendmsg(sock->fd, &msghdr, 0);
send_errno = errno;
/*
diff --git a/lib/isc/unix/stdio.c b/lib/isc/unix/stdio.c
index 90e3b2ab3079..82ef9c255fd4 100644
--- a/lib/isc/unix/stdio.c
+++ b/lib/isc/unix/stdio.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2007, 2011-2013 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004, 2007, 2011-2014 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 2000, 2001 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -54,7 +54,11 @@ isc_result_t
isc_stdio_seek(FILE *f, off_t offset, int whence) {
int r;
+#ifdef HAVE_FSEEKO
r = fseeko(f, offset, whence);
+#else
+ r = fseek(f, offset, whence);
+#endif
if (r == 0)
return (ISC_R_SUCCESS);
else
@@ -67,7 +71,11 @@ isc_stdio_tell(FILE *f, off_t *offsetp) {
REQUIRE(offsetp != NULL);
+#ifdef HAVE_FTELLO
r = ftello(f);
+#else
+ r = ftell(f);
+#endif
if (r >= 0) {
*offsetp = r;
return (ISC_R_SUCCESS);
diff --git a/lib/isc/unix/time.c b/lib/isc/unix/time.c
index 890b9192ba5a..400bbf8f3be0 100644
--- a/lib/isc/unix/time.c
+++ b/lib/isc/unix/time.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004-2008, 2011, 2012, 2014 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004-2008, 2011, 2012, 2014, 2015 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1998-2001, 2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -404,6 +404,9 @@ isc_time_formathttptimestamp(const isc_time_t *t, char *buf, unsigned int len) {
REQUIRE(len > 0);
+ /*
+ * 5 spaces, 1 comma, 3 GMT, 2 %d, 4 %Y, 8 %H:%M:%S, 3+ %a, 3+ %b (29+)
+ */
now = (time_t)t->seconds;
flen = strftime(buf, len, "%a, %d %b %Y %H:%M:%S GMT", gmtime(&now));
INSIST(flen < len);