diff options
| author | Doug Barton <dougb@FreeBSD.org> | 2011-08-02 05:18:50 +0000 |
|---|---|---|
| committer | Doug Barton <dougb@FreeBSD.org> | 2011-08-02 05:18:50 +0000 |
| commit | 0842d663b7cfb84b478ec937fc1dbc640ceae92b (patch) | |
| tree | 4385ddab756952a705f233916d0536e76fe9cc58 /lib/isc | |
| parent | 6a50a75ead6b2f11f0321914c033e8c8670cbb60 (diff) | |
Vendor import of BIND 9.6-ESV-R5vendor/bind9/9.6-ESV-R5
Diffstat (limited to 'lib/isc')
| -rw-r--r-- | lib/isc/api | 4 | ||||
| -rw-r--r-- | lib/isc/heap.c | 9 | ||||
| -rw-r--r-- | lib/isc/httpd.c | 50 | ||||
| -rw-r--r-- | lib/isc/include/isc/file.h | 25 | ||||
| -rw-r--r-- | lib/isc/include/isc/util.h | 9 | ||||
| -rw-r--r-- | lib/isc/log.c | 9 | ||||
| -rw-r--r-- | lib/isc/netaddr.c | 44 | ||||
| -rw-r--r-- | lib/isc/powerpc/include/isc/atomic.h | 22 | ||||
| -rw-r--r-- | lib/isc/radix.c | 6 | ||||
| -rw-r--r-- | lib/isc/rwlock.c | 5 | ||||
| -rw-r--r-- | lib/isc/sha1.c | 6 | ||||
| -rw-r--r-- | lib/isc/sha2.c | 25 | ||||
| -rw-r--r-- | lib/isc/sockaddr.c | 11 | ||||
| -rw-r--r-- | lib/isc/string.c | 11 | ||||
| -rw-r--r-- | lib/isc/timer.c | 11 | ||||
| -rw-r--r-- | lib/isc/unix/dir.c | 6 | ||||
| -rw-r--r-- | lib/isc/unix/file.c | 21 | ||||
| -rw-r--r-- | lib/isc/unix/include/isc/stdtime.h | 8 | ||||
| -rw-r--r-- | lib/isc/unix/socket.c | 58 | ||||
| -rw-r--r-- | lib/isc/unix/stdio.c | 5 | ||||
| -rw-r--r-- | lib/isc/unix/time.c | 6 |
21 files changed, 237 insertions, 114 deletions
diff --git a/lib/isc/api b/lib/isc/api index e1f7b71eb113..0319d830961e 100644 --- a/lib/isc/api +++ b/lib/isc/api @@ -1,3 +1,3 @@ -LIBINTERFACE = 54 +LIBINTERFACE = 55 LIBREVISION = 1 -LIBAGE = 4 +LIBAGE = 5 diff --git a/lib/isc/heap.c b/lib/isc/heap.c index 68f8ba836f3c..9c45a65a0d47 100644 --- a/lib/isc/heap.c +++ b/lib/isc/heap.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2007, 2010 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2007, 2010, 2011 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1997-2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: heap.c,v 1.37.240.3 2010-02-04 23:47:46 tbox Exp $ */ +/* $Id: heap.c,v 1.37.240.5 2011-03-03 23:46:02 tbox Exp $ */ /*! \file * Heap implementation of priority queues adapted from the following: @@ -86,8 +86,9 @@ isc_heap_create(isc_mem_t *mctx, isc_heapcompare_t compare, if (heap == NULL) return (ISC_R_NOMEMORY); heap->magic = HEAP_MAGIC; - heap->mctx = mctx; heap->size = 0; + heap->mctx = NULL; + isc_mem_attach(mctx, &heap->mctx); if (size_increment == 0) heap->size_increment = SIZE_INCREMENT; else @@ -114,7 +115,7 @@ isc_heap_destroy(isc_heap_t **heapp) { isc_mem_put(heap->mctx, heap->array, heap->size * sizeof(void *)); heap->magic = 0; - isc_mem_put(heap->mctx, heap, sizeof(*heap)); + isc_mem_putanddetach(&heap->mctx, heap, sizeof(*heap)); *heapp = NULL; } diff --git a/lib/isc/httpd.c b/lib/isc/httpd.c index b653f7991e2f..74299f8ca0dc 100644 --- a/lib/isc/httpd.c +++ b/lib/isc/httpd.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2008, 2010 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2006-2008, 2010, 2011 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 @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: httpd.c,v 1.16.64.2 2010-02-04 23:47:46 tbox Exp $ */ +/* $Id: httpd.c,v 1.16.64.5 2011-03-11 10:49:57 marka Exp $ */ /*! \file */ @@ -315,7 +315,7 @@ isc_httpdmgr_create(isc_mem_t *mctx, isc_socket_t *sock, isc_task_t *task, isc_task_detach(&httpd->task); isc_socket_detach(&httpd->sock); isc_mem_detach(&httpd->mctx); - isc_mutex_destroy(&httpd->lock); + (void)isc_mutex_destroy(&httpd->lock); isc_mem_put(mctx, httpd, sizeof(isc_httpdmgr_t)); return (result); } @@ -364,7 +364,7 @@ httpdmgr_destroy(isc_httpdmgr_t *httpdmgr) } UNLOCK(&httpdmgr->lock); - isc_mutex_destroy(&httpdmgr->lock); + (void)isc_mutex_destroy(&httpdmgr->lock); if (httpdmgr->ondestroy != NULL) (httpdmgr->ondestroy)(httpdmgr->cb_arg); @@ -586,6 +586,8 @@ isc_httpd_accept(isc_task_t *task, isc_event_t *ev) r.length = HTTP_RECVLEN - 1; result = isc_socket_recv(httpd->sock, &r, 1, task, isc_httpd_recvdone, httpd); + /* FIXME!!! */ + POST(result); NOTICE("accept queued recv on socket"); requeue: @@ -683,8 +685,9 @@ isc_httpd_recvdone(isc_task_t *task, isc_event_t *ev) } r.base = (unsigned char *)httpd->recvbuf + httpd->recvlen; r.length = HTTP_RECVLEN - httpd->recvlen - 1; - result = isc_socket_recv(httpd->sock, &r, 1, task, - isc_httpd_recvdone, httpd); + /* check return code? */ + (void)isc_socket_recv(httpd->sock, &r, 1, task, + isc_httpd_recvdone, httpd); goto out; } else if (result != ISC_R_SUCCESS) { destroy_client(&httpd); @@ -722,14 +725,14 @@ isc_httpd_recvdone(isc_task_t *task, isc_event_t *ev) &httpd->mimetype, &httpd->bodybuffer, &httpd->freecb, &httpd->freecb_arg); if (result != ISC_R_SUCCESS) { - result = httpd->mgr->render_500(httpd->url, httpd->querystring, - NULL, - &httpd->retcode, - &httpd->retmsg, - &httpd->mimetype, - &httpd->bodybuffer, - &httpd->freecb, - &httpd->freecb_arg); + result = httpd->mgr->render_500(httpd->url, httpd->querystring, + NULL, &httpd->retcode, + &httpd->retmsg, + &httpd->mimetype, + &httpd->bodybuffer, + &httpd->freecb, + &httpd->freecb_arg); + RUNTIME_CHECK(result == ISC_R_SUCCESS); } isc_httpd_response(httpd); @@ -753,8 +756,9 @@ isc_httpd_recvdone(isc_task_t *task, isc_event_t *ev) if (isc_buffer_length(&httpd->bodybuffer) > 0) ISC_LIST_APPEND(httpd->bufflist, &httpd->bodybuffer, link); - result = isc_socket_sendv(httpd->sock, &httpd->bufflist, task, - isc_httpd_senddone, httpd); + /* check return code? */ + (void)isc_socket_sendv(httpd->sock, &httpd->bufflist, task, + isc_httpd_senddone, httpd); out: isc_event_free(&ev); @@ -821,7 +825,7 @@ isc_httpd_response(isc_httpd_t *httpd) needlen += 3 + 1; /* room for response code, always 3 bytes */ needlen += strlen(httpd->retmsg) + 2; /* return msg + CRLF */ - if (isc_buffer_availablelength(&httpd->headerbuffer) < needlen) { + while (isc_buffer_availablelength(&httpd->headerbuffer) < needlen) { result = grow_headerspace(httpd); if (result != ISC_R_SUCCESS) return (result); @@ -846,7 +850,7 @@ isc_httpd_addheader(isc_httpd_t *httpd, const char *name, needlen += 2 + strlen(val); /* :<space> and val */ needlen += 2; /* CRLF */ - if (isc_buffer_availablelength(&httpd->headerbuffer) < needlen) { + while (isc_buffer_availablelength(&httpd->headerbuffer) < needlen) { result = grow_headerspace(httpd); if (result != ISC_R_SUCCESS) return (result); @@ -869,7 +873,7 @@ isc_httpd_endheaders(isc_httpd_t *httpd) { isc_result_t result; - if (isc_buffer_availablelength(&httpd->headerbuffer) < 2) { + while (isc_buffer_availablelength(&httpd->headerbuffer) < 2) { result = grow_headerspace(httpd); if (result != ISC_R_SUCCESS) return (result); @@ -893,7 +897,7 @@ isc_httpd_addheaderuint(isc_httpd_t *httpd, const char *name, int val) { needlen += 2 + strlen(buf); /* :<space> and val */ needlen += 2; /* CRLF */ - if (isc_buffer_availablelength(&httpd->headerbuffer) < needlen) { + while (isc_buffer_availablelength(&httpd->headerbuffer) < needlen) { result = grow_headerspace(httpd); if (result != ISC_R_SUCCESS) return (result); @@ -912,7 +916,6 @@ isc_httpd_senddone(isc_task_t *task, isc_event_t *ev) { isc_httpd_t *httpd = ev->ev_arg; isc_region_t r; - isc_result_t result; isc_socketevent_t *sev = (isc_socketevent_t *)ev; ENTER("senddone"); @@ -963,8 +966,9 @@ isc_httpd_senddone(isc_task_t *task, isc_event_t *ev) r.base = (unsigned char *)httpd->recvbuf; r.length = HTTP_RECVLEN - 1; - result = isc_socket_recv(httpd->sock, &r, 1, task, isc_httpd_recvdone, - httpd); + /* check return code? */ + (void)isc_socket_recv(httpd->sock, &r, 1, task, + isc_httpd_recvdone, httpd); out: isc_event_free(&ev); diff --git a/lib/isc/include/isc/file.h b/lib/isc/include/isc/file.h index 6629a3e159ef..89778643e31f 100644 --- a/lib/isc/include/isc/file.h +++ b/lib/isc/include/isc/file.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2007, 2009, 2011 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000, 2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: file.h,v 1.33.332.2 2009-01-18 23:47:41 tbox Exp $ */ +/* $Id: file.h,v 1.33.332.4 2011-03-12 04:57:31 tbox Exp $ */ #ifndef ISC_FILE_H #define ISC_FILE_H 1 @@ -181,6 +181,27 @@ isc_file_isabsolute(const char *filename); * \brief Return #ISC_TRUE if the given file name is absolute. */ +isc_result_t +isc_file_isplainfile(const char *name); +/*!< + * \brief Check that the file is a plain file + * + * Returns: + *\li #ISC_R_SUCCESS + * Success. The file is a plain file. + *\li #ISC_R_INVALIDFILE + * The path specified was not usable by the operating system. + *\li #ISC_R_FILENOTFOUND + * The file does not exist. This return code comes from + * errno=ENOENT when stat returns -1. This code is mentioned + * here, because in logconf.c, it is the one rcode that is + * permitted in addition to ISC_R_SUCCESS. This is done since + * the next call in logconf.c is to isc_stdio_open(), which + * will create the file if it can. + *\li #other ISC_R_* errors translated from errno + * These occur when stat returns -1 and an errno. + */ + isc_boolean_t isc_file_iscurrentdir(const char *filename); /*!< diff --git a/lib/isc/include/isc/util.h b/lib/isc/include/isc/util.h index 8ccad8d9c0cf..668088123cbc 100644 --- a/lib/isc/include/isc/util.h +++ b/lib/isc/include/isc/util.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2007, 2010 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2007, 2010, 2011 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: util.h,v 1.30.332.2 2010-01-11 23:47:22 tbox Exp $ */ +/* $Id: util.h,v 1.30.332.4 2011-03-12 04:57:32 tbox Exp $ */ #ifndef ISC_UTIL_H #define ISC_UTIL_H 1 @@ -48,6 +48,11 @@ */ #define UNUSED(x) (void)(x) +/*% + * The opposite: silent warnings about stored values which are never read. + */ +#define POST(x) (void)(x) + #define ISC_MAX(a, b) ((a) > (b) ? (a) : (b)) #define ISC_MIN(a, b) ((a) < (b) ? (a) : (b)) diff --git a/lib/isc/log.c b/lib/isc/log.c index 121bd25b2567..4694f5e2a4bd 100644 --- a/lib/isc/log.c +++ b/lib/isc/log.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2007, 2009, 2011 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: log.c,v 1.94.332.5 2009-02-16 02:04:05 marka Exp $ */ +/* $Id: log.c,v 1.94.332.7 2011-03-12 04:57:28 tbox Exp $ */ /*! \file * \author Principal Authors: DCL */ @@ -1342,9 +1342,10 @@ isc_log_open(isc_logchannel_t *channel) { (FILE_MAXSIZE(channel) > 0 && statbuf.st_size >= FILE_MAXSIZE(channel))) roll = regular_file; - } else if (errno == ENOENT) + } else if (errno == ENOENT) { regular_file = ISC_TRUE; - else + POST(regular_file); + } else result = ISC_R_INVALIDFILE; /* diff --git a/lib/isc/netaddr.c b/lib/isc/netaddr.c index 92c4fe5b4d4c..aa6aa09152ca 100644 --- a/lib/isc/netaddr.c +++ b/lib/isc/netaddr.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2011 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: netaddr.c,v 1.38 2007-06-18 23:47:44 tbox Exp $ */ +/* $Id: netaddr.c,v 1.38.332.3 2011-03-11 10:49:58 marka Exp $ */ /*! \file */ @@ -69,10 +69,10 @@ isc_boolean_t isc_netaddr_eqprefix(const isc_netaddr_t *a, const isc_netaddr_t *b, unsigned int prefixlen) { - const unsigned char *pa, *pb; - unsigned int ipabytes; /* Length of whole IP address in bytes */ - unsigned int nbytes; /* Number of significant whole bytes */ - unsigned int nbits; /* Number of significant leftover bits */ + const unsigned char *pa = NULL, *pb = NULL; + unsigned int ipabytes = 0; /* Length of whole IP address in bytes */ + unsigned int nbytes; /* Number of significant whole bytes */ + unsigned int nbits; /* Number of significant leftover bits */ REQUIRE(a != NULL && b != NULL); @@ -94,8 +94,6 @@ isc_netaddr_eqprefix(const isc_netaddr_t *a, const isc_netaddr_t *b, ipabytes = 16; break; default: - pa = pb = NULL; /* Avoid silly compiler warning. */ - ipabytes = 0; /* Ditto. */ return (ISC_FALSE); } @@ -188,6 +186,9 @@ isc_netaddr_format(const isc_netaddr_t *na, char *array, unsigned int size) { isc_buffer_init(&buf, array, size); result = isc_netaddr_totext(na, &buf); + if (size == 0) + return; + /* * Null terminate. */ @@ -212,7 +213,7 @@ isc_netaddr_format(const isc_netaddr_t *na, char *array, unsigned int size) { isc_result_t isc_netaddr_prefixok(const isc_netaddr_t *na, unsigned int prefixlen) { static const unsigned char zeros[16]; - unsigned int nbits, nbytes, ipbytes; + unsigned int nbits, nbytes, ipbytes = 0; const unsigned char *p; switch (na->family) { @@ -229,7 +230,6 @@ isc_netaddr_prefixok(const isc_netaddr_t *na, unsigned int prefixlen) { return (ISC_R_RANGE); break; default: - ipbytes = 0; return (ISC_R_NOTIMPLEMENTED); } nbytes = prefixlen / 8; @@ -246,7 +246,7 @@ isc_netaddr_prefixok(const isc_netaddr_t *na, unsigned int prefixlen) { isc_result_t isc_netaddr_masktoprefixlen(const isc_netaddr_t *s, unsigned int *lenp) { - unsigned int nbits, nbytes, ipbytes, i; + unsigned int nbits = 0, nbytes = 0, ipbytes = 0, i; const unsigned char *p; switch (s->family) { @@ -259,10 +259,8 @@ isc_netaddr_masktoprefixlen(const isc_netaddr_t *s, unsigned int *lenp) { ipbytes = 16; break; default: - ipbytes = 0; return (ISC_R_NOTIMPLEMENTED); } - nbytes = nbits = 0; for (i = 0; i < ipbytes; i++) { if (p[i] != 0xFF) break; @@ -303,18 +301,18 @@ isc_netaddr_fromin6(isc_netaddr_t *netaddr, const struct in6_addr *ina6) { isc_result_t isc_netaddr_frompath(isc_netaddr_t *netaddr, const char *path) { #ifdef ISC_PLATFORM_HAVESYSUNH - if (strlen(path) > sizeof(netaddr->type.un) - 1) - return (ISC_R_NOSPACE); - - memset(netaddr, 0, sizeof(*netaddr)); - netaddr->family = AF_UNIX; - strcpy(netaddr->type.un, path); - netaddr->zone = 0; - return (ISC_R_SUCCESS); -#else + if (strlen(path) > sizeof(netaddr->type.un) - 1) + return (ISC_R_NOSPACE); + + memset(netaddr, 0, sizeof(*netaddr)); + netaddr->family = AF_UNIX; + strcpy(netaddr->type.un, path); + netaddr->zone = 0; + return (ISC_R_SUCCESS); +#else UNUSED(netaddr); UNUSED(path); - return (ISC_R_NOTIMPLEMENTED); + return (ISC_R_NOTIMPLEMENTED); #endif } diff --git a/lib/isc/powerpc/include/isc/atomic.h b/lib/isc/powerpc/include/isc/atomic.h index 074fea134298..9e75a407aaa3 100644 --- a/lib/isc/powerpc/include/isc/atomic.h +++ b/lib/isc/powerpc/include/isc/atomic.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2005, 2007, 2009, 2011 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 @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: atomic.h,v 1.6.332.2 2009-10-14 23:47:14 tbox Exp $ */ +/* $Id: atomic.h,v 1.6.332.5 2011-03-08 00:51:27 marka Exp $ */ #ifndef ISC_ATOMIC_H #define ISC_ATOMIC_H 1 @@ -110,14 +110,16 @@ isc_atomic_xadd(isc_int32_t *p, isc_int32_t val) { "mr %0, r6\n" "add r6, r6, %2\n" "stwcx. r6, 0, %1\n" - "bne- 1b" + "bne- 1b\n" + "sync" #else "1:" "lwarx 6, 0, %1\n" "mr %0, 6\n" "add 6, 6, %2\n" "stwcx. 6, 0, %1\n" - "bne- 1b" + "bne- 1b\n" + "sync" #endif : "=&r"(orig) : "r"(p), "r"(val) @@ -135,13 +137,15 @@ isc_atomic_store(void *p, isc_int32_t val) { "lwarx r6, 0, %0\n" "lwz r6, %1\n" "stwcx. r6, 0, %0\n" - "bne- 1b" + "bne- 1b\n" + "sync" #else "1:" "lwarx 6, 0, %0\n" "lwz 6, %1\n" "stwcx. 6, 0, %0\n" - "bne- 1b" + "bne- 1b\n" + "sync" #endif : : "r"(p), "m"(val) @@ -163,7 +167,8 @@ isc_atomic_cmpxchg(isc_int32_t *p, isc_int32_t cmpval, isc_int32_t val) { "mr r6, %3\n" "stwcx. r6, 0, %1\n" "bne- 1b\n" - "2:" + "2:\n" + "sync" #else "1:" "lwarx 6, 0, %1\n" @@ -173,7 +178,8 @@ isc_atomic_cmpxchg(isc_int32_t *p, isc_int32_t cmpval, isc_int32_t val) { "mr 6, %3\n" "stwcx. 6, 0, %1\n" "bne- 1b\n" - "2:" + "2:\n" + "sync" #endif : "=&r" (orig) : "r"(p), "r"(cmpval), "r"(val) diff --git a/lib/isc/radix.c b/lib/isc/radix.c index d72ed3311fa1..9f4bb201a2a8 100644 --- a/lib/isc/radix.c +++ b/lib/isc/radix.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2007-2009, 2011 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 @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: radix.c,v 1.20.36.3 2009-01-18 23:47:41 tbox Exp $ */ +/* $Id: radix.c,v 1.20.36.5 2011-03-12 04:57:28 tbox Exp $ */ /* * This source was adapted from MRT's RCS Ids: @@ -275,7 +275,7 @@ isc_radix_search(isc_radix_tree_t *radix, isc_radix_node_t **target, if (node && node->prefix) stack[cnt++] = node; - while (--cnt >= 0) { + while (cnt-- > 0) { node = stack[cnt]; if (_comp_with_mask(isc_prefix_tochar(node->prefix), diff --git a/lib/isc/rwlock.c b/lib/isc/rwlock.c index 39b90d770728..d0a1d2e43f73 100644 --- a/lib/isc/rwlock.c +++ b/lib/isc/rwlock.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009, 2011 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 @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rwlock.c,v 1.44.332.2 2009-01-18 23:47:41 tbox Exp $ */ +/* $Id: rwlock.c,v 1.44.332.4 2011-03-12 04:57:28 tbox Exp $ */ /*! \file */ @@ -261,6 +261,7 @@ isc_rwlock_lock(isc_rwlock_t *rwl, isc_rwlocktype_t type) { } cntflag = isc_atomic_xadd(&rwl->cnt_and_flag, READER_INCR); + POST(cntflag); while (1) { if ((rwl->cnt_and_flag & WRITER_ACTIVE) == 0) break; diff --git a/lib/isc/sha1.c b/lib/isc/sha1.c index 20ee28d1c338..8af7ecb391d0 100644 --- a/lib/isc/sha1.c +++ b/lib/isc/sha1.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2011 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000, 2001, 2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: sha1.c,v 1.18 2007-06-19 23:47:17 tbox Exp $ */ +/* $Id: sha1.c,v 1.18.332.2 2011-03-12 04:57:28 tbox Exp $ */ /* $NetBSD: sha1.c,v 1.5 2000/01/22 22:19:14 mycroft Exp $ */ /* $OpenBSD: sha1.c,v 1.9 1997/07/23 21:12:32 kstailey Exp $ */ @@ -220,6 +220,8 @@ transform(isc_uint32_t state[5], const unsigned char buffer[64]) { /* Wipe variables */ a = b = c = d = e = 0; + /* Avoid compiler warnings */ + POST(a); POST(b); POST(c); POST(d); POST(e); } diff --git a/lib/isc/sha2.c b/lib/isc/sha2.c index 22f1d47655a4..f72e164c3d99 100644 --- a/lib/isc/sha2.c +++ b/lib/isc/sha2.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2007, 2009, 2010 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2005-2007, 2009-2011 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 @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: sha2.c,v 1.13.332.4 2010-01-15 23:47:34 tbox Exp $ */ +/* $Id: sha2.c,v 1.13.332.6 2011-03-12 04:57:28 tbox Exp $ */ /* $FreeBSD$ */ /* $KAME: sha2.c,v 1.8 2001/11/08 01:07:52 itojun Exp $ */ @@ -570,6 +570,9 @@ void isc_sha256_transform(isc_sha256_t *context, const isc_uint32_t* data) { /* Clean up */ a = b = c = d = e = f = g = h = T1 = 0; + /* Avoid compiler warnings */ + POST(a); POST(b); POST(c); POST(d); POST(e); POST(f); + POST(g); POST(h); POST(T1); } #else /* ISC_SHA2_UNROLL_TRANSFORM */ @@ -651,6 +654,9 @@ isc_sha256_transform(isc_sha256_t *context, const isc_uint32_t* data) { /* Clean up */ a = b = c = d = e = f = g = h = T1 = T2 = 0; + /* Avoid compiler warnings */ + POST(a); POST(b); POST(c); POST(d); POST(e); POST(f); + POST(g); POST(h); POST(T1); POST(T2); } #endif /* ISC_SHA2_UNROLL_TRANSFORM */ @@ -692,6 +698,8 @@ isc_sha256_update(isc_sha256_t *context, const isc_uint8_t *data, size_t len) { context->bitcount += len << 3; /* Clean up: */ usedspace = freespace = 0; + /* Avoid compiler warnings: */ + POST(usedspace); POST(freespace); return; } } @@ -710,6 +718,8 @@ isc_sha256_update(isc_sha256_t *context, const isc_uint8_t *data, size_t len) { } /* Clean up: */ usedspace = freespace = 0; + /* Avoid compiler warnings: */ + POST(usedspace); POST(freespace); } void @@ -780,6 +790,7 @@ isc_sha256_final(isc_uint8_t digest[], isc_sha256_t *context) { /* Clean up state data: */ memset(context, 0, sizeof(context)); usedspace = 0; + POST(usedspace); } char * @@ -917,6 +928,9 @@ void isc_sha512_transform(isc_sha512_t *context, const isc_uint64_t* data) { /* Clean up */ a = b = c = d = e = f = g = h = T1 = 0; + /* Avoid compiler warnings */ + POST(a); POST(b); POST(c); POST(d); POST(e); POST(f); + POST(g); POST(h); POST(T1); } #else /* ISC_SHA2_UNROLL_TRANSFORM */ @@ -996,6 +1010,9 @@ isc_sha512_transform(isc_sha512_t *context, const isc_uint64_t* data) { /* Clean up */ a = b = c = d = e = f = g = h = T1 = T2 = 0; + /* Avoid compiler warnings */ + POST(a); POST(b); POST(c); POST(d); POST(e); POST(f); + POST(g); POST(h); POST(T1); POST(T2); } #endif /* ISC_SHA2_UNROLL_TRANSFORM */ @@ -1037,6 +1054,8 @@ isc_sha512_update(isc_sha512_t *context, const isc_uint8_t *data, size_t len) { ADDINC128(context->bitcount, len << 3); /* Clean up: */ usedspace = freespace = 0; + /* Avoid compiler warnings: */ + POST(usedspace); POST(freespace); return; } } @@ -1055,6 +1074,8 @@ isc_sha512_update(isc_sha512_t *context, const isc_uint8_t *data, size_t len) { } /* Clean up: */ usedspace = freespace = 0; + /* Avoid compiler warnings: */ + POST(usedspace); POST(freespace); } void isc_sha512_last(isc_sha512_t *context) { diff --git a/lib/isc/sockaddr.c b/lib/isc/sockaddr.c index 19833e4fa1eb..424430efd24a 100644 --- a/lib/isc/sockaddr.c +++ b/lib/isc/sockaddr.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2007, 2011 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: sockaddr.c,v 1.70 2007-06-19 23:47:17 tbox Exp $ */ +/* $Id: sockaddr.c,v 1.70.332.2 2011-02-21 23:45:49 tbox Exp $ */ /*! \file */ @@ -182,6 +182,9 @@ isc_sockaddr_format(const isc_sockaddr_t *sa, char *array, unsigned int size) { 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) { @@ -390,8 +393,8 @@ isc_sockaddr_fromnetaddr(isc_sockaddr_t *sockaddr, const isc_netaddr_t *na, #endif sockaddr->type.sin6.sin6_port = htons(port); break; - default: - INSIST(0); + default: + INSIST(0); } ISC_LINK_INIT(sockaddr, link); } diff --git a/lib/isc/string.c b/lib/isc/string.c index 3bcea3a2352a..095323f7cc88 100644 --- a/lib/isc/string.c +++ b/lib/isc/string.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2007, 2011 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2001, 2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: string.c,v 1.20 2007-06-19 23:47:17 tbox Exp $ */ +/* $Id: string.c,v 1.20.332.2 2011-03-12 04:57:28 tbox Exp $ */ /*! \file */ @@ -165,14 +165,15 @@ isc_string_printf(char *target, size_t size, const char *format, ...) { } void -isc_string_printf_truncate(char *target, size_t size, const char *format, ...) { +isc_string_printf_truncate(char *target, size_t size, const char *format, ...) +{ va_list args; - size_t n; REQUIRE(size > 0U); va_start(args, format); - n = vsnprintf(target, size, format, args); + /* check return code? */ + (void)vsnprintf(target, size, format, args); va_end(args); ENSURE(strlen(target) < size); diff --git a/lib/isc/timer.c b/lib/isc/timer.c index 634268831dec..1e2c95503566 100644 --- a/lib/isc/timer.c +++ b/lib/isc/timer.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007-2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007-2009, 2011 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: timer.c,v 1.84.58.4 2009-01-23 23:47:21 tbox Exp $ */ +/* $Id: timer.c,v 1.84.58.6 2011-03-12 04:57:28 tbox Exp $ */ /*! \file */ @@ -243,7 +243,9 @@ schedule(isc_timer_t *timer, isc_time_t *now, isc_boolean_t signal_ok) { static inline void deschedule(isc_timer_t *timer) { +#ifdef ISC_PLATFORM_USETHREADS isc_boolean_t need_wakeup = ISC_FALSE; +#endif isc_timermgr_t *manager; /* @@ -252,8 +254,10 @@ deschedule(isc_timer_t *timer) { manager = timer->manager; if (timer->index > 0) { +#ifdef ISC_PLATFORM_USETHREADS if (timer->index == 1) need_wakeup = ISC_TRUE; +#endif isc_heap_delete(manager->heap, timer->index); timer->index = 0; INSIST(manager->nscheduled > 0); @@ -431,6 +435,7 @@ isc_timer_reset(isc_timer_t *timer, isc_timertype_t type, REQUIRE(VALID_TIMER(timer)); manager = timer->manager; REQUIRE(VALID_MANAGER(manager)); + if (expires == NULL) expires = isc_time_epoch; if (interval == NULL) @@ -454,8 +459,6 @@ isc_timer_reset(isc_timer_t *timer, isc_timertype_t type, isc_time_settoepoch(&now); } - manager = timer->manager; - LOCK(&manager->lock); LOCK(&timer->lock); diff --git a/lib/isc/unix/dir.c b/lib/isc/unix/dir.c index 8053c42980ef..12f8eb0c6337 100644 --- a/lib/isc/unix/dir.c +++ b/lib/isc/unix/dir.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009, 2011 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dir.c,v 1.25.332.3 2009-02-16 23:47:15 tbox Exp $ */ +/* $Id: dir.c,v 1.25.332.5 2011-03-12 04:57:32 tbox Exp $ */ /*! \file * \author Principal Authors: DCL */ @@ -79,7 +79,7 @@ isc_dir_open(isc_dir_t *dir, const char *dirname) { if (dir->dirname < p && *(p - 1) != '/') *p++ = '/'; *p++ = '*'; - *p++ = '\0'; + *p = '\0'; /* * Open stream. diff --git a/lib/isc/unix/file.c b/lib/isc/unix/file.c index ae737b8bf9be..ce6a2892639b 100644 --- a/lib/isc/unix/file.c +++ b/lib/isc/unix/file.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009, 2011 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -48,7 +48,7 @@ * SUCH DAMAGE. */ -/* $Id: file.c,v 1.51.332.2 2009-02-16 23:47:15 tbox Exp $ */ +/* $Id: file.c,v 1.51.332.4 2011-03-12 04:57:32 tbox Exp $ */ /*! \file */ @@ -338,6 +338,23 @@ isc_file_exists(const char *pathname) { return (ISC_TF(file_stats(pathname, &stats) == ISC_R_SUCCESS)); } +isc_result_t +isc_file_isplainfile(const char *filename) { + /* + * This function returns success if filename is a plain file. + */ + struct stat filestat; + memset(&filestat,0,sizeof(struct stat)); + + if ((stat(filename, &filestat)) == -1) + return(isc__errno2result(errno)); + + if(! S_ISREG(filestat.st_mode)) + return(ISC_R_INVALIDFILE); + + return(ISC_R_SUCCESS); +} + isc_boolean_t isc_file_isabsolute(const char *filename) { REQUIRE(filename != NULL); diff --git a/lib/isc/unix/include/isc/stdtime.h b/lib/isc/unix/include/isc/stdtime.h index 581e6f77b041..80fd9d30ebc2 100644 --- a/lib/isc/unix/include/isc/stdtime.h +++ b/lib/isc/unix/include/isc/stdtime.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2011 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: stdtime.h,v 1.14 2007-06-19 23:47:19 tbox Exp $ */ +/* $Id: stdtime.h,v 1.14.332.2 2011-03-18 23:46:08 tbox Exp $ */ #ifndef ISC_STDTIME_H #define ISC_STDTIME_H 1 @@ -31,6 +31,10 @@ * about its size. */ typedef isc_uint32_t isc_stdtime_t; + +/* but this flag helps... */ +#define STDTIME_ON_32BITS 1 + /* * isc_stdtime32_t is a 32-bit version of isc_stdtime_t. A variable of this * type should only be used as an opaque integer (e.g.,) to compare two diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index 055e8837684c..18a94c4d40f7 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2010 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2011 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: socket.c,v 1.308.12.17 2010-12-22 03:28:13 marka Exp $ */ +/* $Id: socket.c,v 1.308.12.22 2011-07-21 23:46:12 tbox Exp $ */ /*! \file */ @@ -1206,6 +1206,9 @@ build_msghdr_send(isc_socket_t *sock, isc_socketevent_t *dev, #if defined(USE_CMSG) && defined(ISC_PLATFORM_HAVEIN6PKTINFO) if ((sock->type == isc_sockettype_udp) && ((dev->attributes & ISC_SOCKEVENTATTR_PKTINFO) != 0)) { +#if defined(IPV6_USE_MIN_MTU) + int use_min_mtu = 1; /* -1, 0, 1 */ +#endif struct cmsghdr *cmsgp; struct in6_pktinfo *pktinfop; @@ -1224,6 +1227,22 @@ build_msghdr_send(isc_socket_t *sock, isc_socketevent_t *dev, cmsgp->cmsg_len = cmsg_len(sizeof(struct in6_pktinfo)); pktinfop = (struct in6_pktinfo *)CMSG_DATA(cmsgp); memcpy(pktinfop, &dev->pktinfo, sizeof(struct in6_pktinfo)); +#if defined(IPV6_USE_MIN_MTU) + /* + * Set IPV6_USE_MIN_MTU as a per packet option as FreeBSD + * ignores setsockopt(IPV6_USE_MIN_MTU) when IPV6_PKTINFO + * is used. + */ + cmsgp = (struct cmsghdr *)(sock->sendcmsgbuf + + msg->msg_controllen); + msg->msg_controllen += cmsg_space(sizeof(use_min_mtu)); + INSIST(msg->msg_controllen <= sock->sendcmsgbuflen); + + cmsgp->cmsg_level = IPPROTO_IPV6; + cmsgp->cmsg_type = IPV6_USE_MIN_MTU; + cmsgp->cmsg_len = cmsg_len(sizeof(use_min_mtu)); + memcpy(CMSG_DATA(cmsgp), &use_min_mtu, sizeof(use_min_mtu)); +#endif } #endif /* USE_CMSG && ISC_PLATFORM_HAVEIPV6 */ #else /* ISC_NET_BSD44MSGHDR */ @@ -1594,6 +1613,7 @@ doio_recv(isc_socket_t *sock, isc_socketevent_t *dev) { } else { isc_buffer_add(buffer, actual_count); actual_count = 0; + POST(actual_count); break; } buffer = ISC_LIST_NEXT(buffer, link); @@ -1833,9 +1853,10 @@ destroy(isc_socket_t **sockp) { SIGNAL(&manager->shutdown_ok); #endif /* ISC_PLATFORM_USETHREADS */ - UNLOCK(&manager->lock); - + /* can't unlock manager as its memory context is still used */ free_socket(sockp); + + UNLOCK(&manager->lock); } static isc_result_t @@ -1871,7 +1892,7 @@ allocate_socket(isc_socketmgr_t *manager, isc_sockettype_t type, */ cmsgbuflen = 0; #if defined(USE_CMSG) && defined(ISC_PLATFORM_HAVEIN6PKTINFO) - cmsgbuflen = cmsg_space(sizeof(struct in6_pktinfo)); + cmsgbuflen += cmsg_space(sizeof(struct in6_pktinfo)); #endif #if defined(USE_CMSG) && defined(SO_TIMESTAMP) cmsgbuflen += cmsg_space(sizeof(struct timeval)); @@ -1885,7 +1906,14 @@ allocate_socket(isc_socketmgr_t *manager, isc_sockettype_t type, cmsgbuflen = 0; #if defined(USE_CMSG) && defined(ISC_PLATFORM_HAVEIN6PKTINFO) - cmsgbuflen = cmsg_space(sizeof(struct in6_pktinfo)); + cmsgbuflen += cmsg_space(sizeof(struct in6_pktinfo)); +#if defined(IPV6_USE_MIN_MTU) + /* + * Provide space for working around FreeBSD's broken IPV6_USE_MIN_MTU + * support. + */ + cmsgbuflen += cmsg_space(sizeof(int)); +#endif #endif sock->sendcmsgbuflen = cmsgbuflen; if (sock->sendcmsgbuflen != 0U) { @@ -2232,10 +2260,18 @@ opensocket(isc_socketmgr_t *manager, isc_socket_t *sock) { #endif /* ISC_PLATFORM_HAVEIN6PKTINFO */ #ifdef IPV6_USE_MIN_MTU /* RFC 3542, not too common yet*/ /* use minimum MTU */ - if (sock->pf == AF_INET6) { - (void)setsockopt(sock->fd, IPPROTO_IPV6, - IPV6_USE_MIN_MTU, - (void *)&on, sizeof(on)); + if (sock->pf == AF_INET6 && + setsockopt(sock->fd, IPPROTO_IPV6, IPV6_USE_MIN_MTU, + (void *)&on, sizeof(on)) < 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); + UNEXPECTED_ERROR(__FILE__, __LINE__, + "setsockopt(%d, IPV6_USE_MIN_MTU) " + "%s: %s", sock->fd, + isc_msgcat_get(isc_msgcat, + ISC_MSGSET_GENERAL, + ISC_MSG_FAILED, + "failed"), + strbuf); } #endif #if defined(IPV6_MTU) @@ -2538,7 +2574,6 @@ isc_result_t isc_socket_close(isc_socket_t *sock) { int fd; isc_socketmgr_t *manager; - isc_sockettype_t type; REQUIRE(VALID_SOCKET(sock)); @@ -2558,7 +2593,6 @@ isc_socket_close(isc_socket_t *sock) { INSIST(sock->connect_ev == NULL); manager = sock->manager; - type = sock->type; fd = sock->fd; sock->fd = -1; memset(sock->name, 0, sizeof(sock->name)); diff --git a/lib/isc/unix/stdio.c b/lib/isc/unix/stdio.c index ff3a527b4745..90ee6dbfb6fd 100644 --- a/lib/isc/unix/stdio.c +++ b/lib/isc/unix/stdio.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2007, 2011 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000, 2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: stdio.c,v 1.8 2007-06-19 23:47:18 tbox Exp $ */ +/* $Id: stdio.c,v 1.8.332.2 2011-03-12 04:57:32 tbox Exp $ */ #include <config.h> @@ -23,6 +23,7 @@ #include <unistd.h> #include <isc/stdio.h> +#include <isc/stat.h> #include "errno2result.h" diff --git a/lib/isc/unix/time.c b/lib/isc/unix/time.c index 1dc05b87a698..1865cdb42e9b 100644 --- a/lib/isc/unix/time.c +++ b/lib/isc/unix/time.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2008, 2011 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 @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: time.c,v 1.56 2008-02-15 23:46:51 tbox Exp $ */ +/* $Id: time.c,v 1.56.134.2 2011-03-12 04:57:32 tbox Exp $ */ /*! \file */ @@ -319,7 +319,7 @@ isc_time_microdiff(const isc_time_t *t1, const isc_time_t *t2) { /* * Convert to microseconds. */ - i3 = (i1 - i2) / NS_PER_US; + i3 /= NS_PER_US; return (i3); } |
