diff options
| author | Doug Barton <dougb@FreeBSD.org> | 2010-03-02 19:49:55 +0000 |
|---|---|---|
| committer | Doug Barton <dougb@FreeBSD.org> | 2010-03-02 19:49:55 +0000 |
| commit | 841024d54f1f0a07feccf84d8938b00bc1f362b5 (patch) | |
| tree | c470abc978aa6ca4f6b0033d7e09c8b7b09cd629 /lib/isc | |
| parent | 51917575cfd35d6a201b010726ea7404a0f9bb7e (diff) | |
Diffstat (limited to 'lib/isc')
| -rw-r--r-- | lib/isc/api | 4 | ||||
| -rw-r--r-- | lib/isc/base32.c | 4 | ||||
| -rw-r--r-- | lib/isc/base64.c | 8 | ||||
| -rw-r--r-- | lib/isc/heap.c | 14 | ||||
| -rw-r--r-- | lib/isc/httpd.c | 45 | ||||
| -rw-r--r-- | lib/isc/ia64/include/isc/atomic.h | 8 | ||||
| -rw-r--r-- | lib/isc/include/isc/entropy.h | 14 | ||||
| -rw-r--r-- | lib/isc/include/isc/netscope.h | 6 | ||||
| -rw-r--r-- | lib/isc/include/isc/portset.h | 4 | ||||
| -rw-r--r-- | lib/isc/include/isc/sha2.h | 10 | ||||
| -rw-r--r-- | lib/isc/include/isc/util.h | 14 | ||||
| -rw-r--r-- | lib/isc/inet_ntop.c | 11 | ||||
| -rw-r--r-- | lib/isc/powerpc/include/isc/atomic.h | 53 | ||||
| -rw-r--r-- | lib/isc/random.c | 27 | ||||
| -rw-r--r-- | lib/isc/sha2.c | 27 | ||||
| -rw-r--r-- | lib/isc/unix/ifiter_getifaddrs.c | 6 | ||||
| -rw-r--r-- | lib/isc/unix/socket.c | 31 |
17 files changed, 209 insertions, 77 deletions
diff --git a/lib/isc/api b/lib/isc/api index 5ef8dc035a3e..e55996b2690b 100644 --- a/lib/isc/api +++ b/lib/isc/api @@ -1,3 +1,3 @@ -LIBINTERFACE = 51 +LIBINTERFACE = 52 LIBREVISION = 1 -LIBAGE = 1 +LIBAGE = 2 diff --git a/lib/isc/base32.c b/lib/isc/base32.c index 3000a84f2da1..d324da9760ae 100644 --- a/lib/isc/base32.c +++ b/lib/isc/base32.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: base32.c,v 1.3.116.2 2009/01/18 23:47:41 tbox Exp $ */ +/* $Id: base32.c,v 1.3.116.3 2009/10/21 01:22:47 each Exp $ */ /*! \file */ @@ -112,6 +112,8 @@ base32_totext(isc_region_t *source, int wordlength, const char *wordbreak, RETERR(str_totext(wordbreak, target)); } } + if (source->length > 0) + isc_region_consume(source, source->length); return (ISC_R_SUCCESS); } diff --git a/lib/isc/base64.c b/lib/isc/base64.c index 13ed6b5c5c17..4844a4bf75b7 100644 --- a/lib/isc/base64.c +++ b/lib/isc/base64.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009 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: base64.c,v 1.32 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: base64.c,v 1.32.332.2 2009/10/21 23:47:20 tbox Exp $ */ /*! \file */ @@ -85,11 +85,13 @@ isc_base64_totext(isc_region_t *source, int wordlength, buf[2] = base64[((source->base[1]<<2)&0x3c)]; buf[3] = '='; RETERR(str_totext(buf, target)); + isc_region_consume(source, 2); } else if (source->length == 1) { buf[0] = base64[(source->base[0]>>2)&0x3f]; buf[1] = base64[((source->base[0]<<4)&0x30)]; buf[2] = buf[3] = '='; RETERR(str_totext(buf, target)); + isc_region_consume(source, 1); } return (ISC_R_SUCCESS); } @@ -217,7 +219,7 @@ isc_base64_decodestring(const char *cstr, isc_buffer_t *target) { continue; RETERR(base64_decode_char(&ctx, c)); } - RETERR(base64_decode_finish(&ctx)); + RETERR(base64_decode_finish(&ctx)); return (ISC_R_SUCCESS); } diff --git a/lib/isc/heap.c b/lib/isc/heap.c index 91d78c06d468..dc32100d2f18 100644 --- a/lib/isc/heap.c +++ b/lib/isc/heap.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2007, 2010 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 2007/10/19 17:15:53 explorer Exp $ */ +/* $Id: heap.c,v 1.37.240.3 2010/02/04 23:47:46 tbox Exp $ */ /*! \file * Heap implementation of priority queues adapted from the following: @@ -186,15 +186,17 @@ sink_down(isc_heap_t *heap, unsigned int i, void *elt) { isc_result_t isc_heap_insert(isc_heap_t *heap, void *elt) { - unsigned int i; + unsigned int new_last; REQUIRE(VALID_HEAP(heap)); - i = ++heap->last; - if (heap->last >= heap->size && !resize(heap)) + new_last = heap->last + 1; + RUNTIME_CHECK(new_last > 0); /* overflow check */ + if (new_last >= heap->size && !resize(heap)) return (ISC_R_NOMEMORY); + heap->last = new_last; - float_up(heap, i, elt); + float_up(heap, new_last, elt); return (ISC_R_SUCCESS); } diff --git a/lib/isc/httpd.c b/lib/isc/httpd.c index fa313253b3e9..066939d1f41e 100644 --- a/lib/isc/httpd.c +++ b/lib/isc/httpd.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2008 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2006-2008, 2010 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 2008/08/08 05:06:49 marka Exp $ */ +/* $Id: httpd.c,v 1.16.64.2 2010/02/04 23:47:46 tbox Exp $ */ /*! \file */ @@ -151,6 +151,7 @@ struct isc_httpdmgr { ISC_LIST(isc_httpdurl_t) urls; /*%< urls we manage */ isc_httpdaction_t *render_404; + isc_httpdaction_t *render_500; }; /*% @@ -221,6 +222,11 @@ static isc_result_t render_404(const char *, const char *, unsigned int *, const char **, const char **, isc_buffer_t *, isc_httpdfree_t **, void **); +static isc_result_t render_500(const char *, const char *, + void *, + unsigned int *, const char **, + const char **, isc_buffer_t *, + isc_httpdfree_t **, void **); static void destroy_client(isc_httpd_t **httpdp) @@ -300,6 +306,7 @@ isc_httpdmgr_create(isc_mem_t *mctx, isc_socket_t *sock, isc_task_t *task, goto cleanup; httpd->render_404 = render_404; + httpd->render_500 = render_500; *httpdp = httpd; return (ISC_R_SUCCESS); @@ -623,6 +630,30 @@ render_404(const char *url, const char *querystring, return (ISC_R_SUCCESS); } +static isc_result_t +render_500(const char *url, const char *querystring, + void *arg, + unsigned int *retcode, const char **retmsg, + const char **mimetype, isc_buffer_t *b, + isc_httpdfree_t **freecb, void **freecb_args) +{ + static char msg[] = "Internal server failure."; + + UNUSED(url); + UNUSED(querystring); + UNUSED(arg); + + *retcode = 500; + *retmsg = "Internal server failure"; + *mimetype = "text/plain"; + isc_buffer_reinit(b, msg, strlen(msg)); + isc_buffer_add(b, strlen(msg)); + *freecb = NULL; + *freecb_args = NULL; + + return (ISC_R_SUCCESS); +} + static void isc_httpd_recvdone(isc_task_t *task, isc_event_t *ev) { @@ -691,8 +722,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) { - destroy_client(&httpd); - goto out; + result = httpd->mgr->render_500(httpd->url, httpd->querystring, + NULL, + &httpd->retcode, + &httpd->retmsg, + &httpd->mimetype, + &httpd->bodybuffer, + &httpd->freecb, + &httpd->freecb_arg); } isc_httpd_response(httpd); diff --git a/lib/isc/ia64/include/isc/atomic.h b/lib/isc/ia64/include/isc/atomic.h index 4c4679772044..d825819de3ff 100644 --- a/lib/isc/ia64/include/isc/atomic.h +++ b/lib/isc/ia64/include/isc/atomic.h @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: atomic.h,v 1.4.326.2 2009/02/06 23:47:11 tbox Exp $ */ +/* $Id: atomic.h,v 1.4.326.3 2009/06/24 02:21:28 marka Exp $ */ #ifndef ISC_ATOMIC_H #define ISC_ATOMIC_H 1 @@ -31,10 +31,10 @@ * (e.g., 1 and -1)? */ static inline isc_int32_t -isc_atomic_xadd(isc_int32_t *p, isc_int32_t val) #ifdef __GNUC__ __attribute__ ((unused)) #endif +isc_atomic_xadd(isc_int32_t *p, isc_int32_t val) { isc_int32_t prev, swapped; @@ -57,10 +57,10 @@ __attribute__ ((unused)) * This routine atomically stores the value 'val' in 'p'. */ static inline void -isc_atomic_store(isc_int32_t *p, isc_int32_t val) #ifdef __GNUC__ __attribute__ ((unused)) #endif +isc_atomic_store(isc_int32_t *p, isc_int32_t val) { __asm__ volatile( "st4.rel %0=%1" @@ -76,10 +76,10 @@ __attribute__ ((unused)) * case. */ static inline isc_int32_t -isc_atomic_cmpxchg(isc_int32_t *p, isc_int32_t cmpval, isc_int32_t val) #ifdef __GNUC__ __attribute__ ((unused)) #endif +isc_atomic_cmpxchg(isc_int32_t *p, isc_int32_t cmpval, isc_int32_t val) { isc_int32_t ret; diff --git a/lib/isc/include/isc/entropy.h b/lib/isc/include/isc/entropy.h index e9e59c495141..125669ca856d 100644 --- a/lib/isc/include/isc/entropy.h +++ b/lib/isc/include/isc/entropy.h @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: entropy.h,v 1.32.332.2 2009/01/18 23:47:41 tbox Exp $ */ +/* $Id: entropy.h,v 1.32.332.3 2009/10/19 02:46:07 marka Exp $ */ #ifndef ISC_ENTROPY_H #define ISC_ENTROPY_H 1 @@ -182,8 +182,8 @@ isc_result_t isc_entropy_createsamplesource(isc_entropy_t *ent, isc_entropysource_t **sourcep); /*!< - * \brief Create an entropy source that consists of samples. Each sample is added - * to the source via isc_entropy_addsamples(), below. + * \brief Create an entropy source that consists of samples. Each sample is + * added to the source via isc_entropy_addsamples(), below. */ isc_result_t @@ -254,11 +254,11 @@ void isc_entropy_putdata(isc_entropy_t *ent, void *data, unsigned int length, isc_uint32_t entropy); /*!< - * \brief Add "length" bytes in "data" to the entropy pool, incrementing the pool's - * entropy count by "entropy." + * \brief Add "length" bytes in "data" to the entropy pool, incrementing the + * pool's entropy count by "entropy." * - * These bytes will prime the pseudorandom portion even no entropy is actually - * added. + * These bytes will prime the pseudorandom portion even if no entropy is + * actually added. */ void diff --git a/lib/isc/include/isc/netscope.h b/lib/isc/include/isc/netscope.h index ba4e792a40a4..0883140acdb5 100644 --- a/lib/isc/include/isc/netscope.h +++ b/lib/isc/include/isc/netscope.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 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: netscope.h,v 1.11 2007/06/19 23:47:18 tbox Exp $ */ +/* $Id: netscope.h,v 1.11.332.2 2009/06/25 23:47:24 tbox Exp $ */ #ifndef ISC_NETSCOPE_H #define ISC_NETSCOPE_H 1 @@ -40,4 +40,4 @@ isc_netscope_pton(int af, char *scopename, void *addr, isc_uint32_t *zoneid); ISC_LANG_ENDDECLS -#endif /* ISC_NETADDR_H */ +#endif /* ISC_NETSCOPE_H */ diff --git a/lib/isc/include/isc/portset.h b/lib/isc/include/isc/portset.h index dc1f85616eab..a7ad3d695324 100644 --- a/lib/isc/include/isc/portset.h +++ b/lib/isc/include/isc/portset.h @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: portset.h,v 1.3.90.2 2009/01/18 23:47:41 tbox Exp $ */ +/* $Id: portset.h,v 1.3.90.3 2009/06/25 05:31:51 marka Exp $ */ /*! \file isc/portset.h * \brief Transport Protocol Port Manipulation Module @@ -138,4 +138,4 @@ isc_portset_removerange(isc_portset_t *portset, in_port_t port_lo, ISC_LANG_ENDDECLS -#endif /* ISC_NETADDR_H */ +#endif /* ISC_PORTSET_H */ diff --git a/lib/isc/include/isc/sha2.h b/lib/isc/include/isc/sha2.h index 211e25505a95..edafa611bc22 100644 --- a/lib/isc/include/isc/sha2.h +++ b/lib/isc/include/isc/sha2.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2005-2007, 2010 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.h,v 1.9 2007/06/19 23:47:18 tbox Exp $ */ +/* $Id: sha2.h,v 1.9.332.2 2010/01/15 23:47:34 tbox Exp $ */ /* $FreeBSD$ */ /* $KAME: sha2.h,v 1.3 2001/03/12 08:27:48 itojun Exp $ */ @@ -39,7 +39,7 @@ * 3. Neither the name of the copyright holder nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTOR(S) ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -104,24 +104,28 @@ typedef isc_sha512_t isc_sha384_t; /*** SHA-224/256/384/512 Function Prototypes ******************************/ void isc_sha224_init (isc_sha224_t *); +void isc_sha224_invalidate (isc_sha224_t *); void isc_sha224_update (isc_sha224_t *, const isc_uint8_t *, size_t); void isc_sha224_final (isc_uint8_t[ISC_SHA224_DIGESTLENGTH], isc_sha224_t *); char *isc_sha224_end (isc_sha224_t *, char[ISC_SHA224_DIGESTSTRINGLENGTH]); char *isc_sha224_data (const isc_uint8_t *, size_t, char[ISC_SHA224_DIGESTSTRINGLENGTH]); void isc_sha256_init (isc_sha256_t *); +void isc_sha256_invalidate (isc_sha256_t *); void isc_sha256_update (isc_sha256_t *, const isc_uint8_t *, size_t); void isc_sha256_final (isc_uint8_t[ISC_SHA256_DIGESTLENGTH], isc_sha256_t *); char *isc_sha256_end (isc_sha256_t *, char[ISC_SHA256_DIGESTSTRINGLENGTH]); char *isc_sha256_data (const isc_uint8_t *, size_t, char[ISC_SHA256_DIGESTSTRINGLENGTH]); void isc_sha384_init (isc_sha384_t *); +void isc_sha384_invalidate (isc_sha384_t *); void isc_sha384_update (isc_sha384_t *, const isc_uint8_t *, size_t); void isc_sha384_final (isc_uint8_t[ISC_SHA384_DIGESTLENGTH], isc_sha384_t *); char *isc_sha384_end (isc_sha384_t *, char[ISC_SHA384_DIGESTSTRINGLENGTH]); char *isc_sha384_data (const isc_uint8_t *, size_t, char[ISC_SHA384_DIGESTSTRINGLENGTH]); void isc_sha512_init (isc_sha512_t *); +void isc_sha512_invalidate (isc_sha512_t *); void isc_sha512_update (isc_sha512_t *, const isc_uint8_t *, size_t); void isc_sha512_final (isc_uint8_t[ISC_SHA512_DIGESTLENGTH], isc_sha512_t *); char *isc_sha512_end (isc_sha512_t *, char[ISC_SHA512_DIGESTSTRINGLENGTH]); diff --git a/lib/isc/include/isc/util.h b/lib/isc/include/isc/util.h index 8a3b95d9da36..85846b6e807b 100644 --- a/lib/isc/include/isc/util.h +++ b/lib/isc/include/isc/util.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2007, 2010 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 2007/06/19 23:47:18 tbox Exp $ */ +/* $Id: util.h,v 1.30.332.2 2010/01/11 23:47:22 tbox Exp $ */ #ifndef ISC_UTIL_H #define ISC_UTIL_H 1 @@ -230,4 +230,14 @@ */ #define TIME_NOW(tp) RUNTIME_CHECK(isc_time_now((tp)) == ISC_R_SUCCESS) +/*% + * Prevent Linux spurious warnings + */ +#if defined(__GNUC__) && (__GNUC__ > 3) +#define isc_util_fwrite(a, b, c, d) \ + __builtin_expect(fwrite((a), (b), (c), (d)), (c)) +#else +#define isc_util_fwrite(a, b, c, d) fwrite((a), (b), (c), (d)) +#endif + #endif /* ISC_UTIL_H */ diff --git a/lib/isc/inet_ntop.c b/lib/isc/inet_ntop.c index dc053ededfba..c37be5c0b5b8 100644 --- a/lib/isc/inet_ntop.c +++ b/lib/isc/inet_ntop.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1996-2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -19,7 +19,7 @@ #if defined(LIBC_SCCS) && !defined(lint) static char rcsid[] = - "$Id: inet_ntop.c,v 1.19 2007/06/19 23:47:17 tbox Exp $"; + "$Id: inet_ntop.c,v 1.19.332.2 2009/07/18 23:47:25 tbox Exp $"; #endif /* LIBC_SCCS and not lint */ #include <config.h> @@ -52,7 +52,7 @@ static const char *inet_ntop6(const unsigned char *src, char *dst, * convert a network format address to presentation format. * \return * pointer to presentation format address (`dst'), or NULL (see errno). - * \author + * \author * Paul Vixie, 1996. */ const char * @@ -169,8 +169,9 @@ inet_ntop6(const unsigned char *src, char *dst, size_t size) if (i != 0) *tp++ = ':'; /* Is this address an encapsulated IPv4? */ - if (i == 6 && best.base == 0 && - (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) { + if (i == 6 && best.base == 0 && (best.len == 6 || + (best.len == 7 && words[7] != 0x0001) || + (best.len == 5 && words[5] == 0xffff))) { if (!inet_ntop4(src+12, tp, sizeof(tmp) - (tp - tmp))) return (NULL); diff --git a/lib/isc/powerpc/include/isc/atomic.h b/lib/isc/powerpc/include/isc/atomic.h index 765cb6d72a8c..2114767b361d 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 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2005, 2007, 2009 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 2007/06/18 23:47:47 tbox Exp $ */ +/* $Id: atomic.h,v 1.6.332.2 2009/10/14 23:47:14 tbox Exp $ */ #ifndef ISC_ATOMIC_H #define ISC_ATOMIC_H 1 @@ -46,25 +46,56 @@ #include <sys/atomic_op.h> -#define isc_atomic_xadd(p, v) fetch_and_add(p, v) #define isc_atomic_store(p, v) _clear_lock(p, v) #ifdef __GNUC__ +static inline isc_int32_t +#else +static isc_int32_t +#endif +isc_atomic_xadd(isc_int32_t *p, isc_int32_t val) { + int ret; + +#ifdef __GNUC__ + asm("ics"); +#else + __isync(); +#endif + + ret = fetch_and_add((atomic_p)p, (int)val); + +#ifdef __GNUC__ + asm("ics"); +#else + __isync(); +#endif + + return (ret); +} + +#ifdef __GNUC__ static inline int #else static int #endif isc_atomic_cmpxchg(atomic_p p, int old, int new) { - int orig = old; + int orig = old; #ifdef __GNUC__ - asm("ics"); + asm("ics"); #else - __isync(); + __isync(); #endif - if (compare_and_swap(p, &orig, new)) - return (old); - return (orig); + if (compare_and_swap(p, &orig, new)) + orig = old; + +#ifdef __GNUC__ + asm("ics"); +#else + __isync(); +#endif + + return (orig); } #elif defined(ISC_PLATFORM_USEGCCASM) || defined(ISC_PLATFORM_USEMACASM) @@ -76,14 +107,14 @@ isc_atomic_xadd(isc_int32_t *p, isc_int32_t val) { #ifdef ISC_PLATFORM_USEMACASM "1:" "lwarx r6, 0, %1\n" - "mr %0, r6\n" + "mr %0, r6\n" "add r6, r6, %2\n" "stwcx. r6, 0, %1\n" "bne- 1b" #else "1:" "lwarx 6, 0, %1\n" - "mr %0, 6\n" + "mr %0, 6\n" "add 6, 6, %2\n" "stwcx. 6, 0, %1\n" "bne- 1b" diff --git a/lib/isc/random.c b/lib/isc/random.c index 0329abde72b2..84ba6a0daab2 100644 --- a/lib/isc/random.c +++ b/lib/isc/random.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009 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: random.c,v 1.25 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: random.c,v 1.25.332.2 2009/07/16 23:47:17 tbox Exp $ */ /*! \file */ @@ -43,7 +43,7 @@ initialize_rand(void) { #ifndef HAVE_ARC4RANDOM unsigned int pid = getpid(); - + /* * The low bits of pid generally change faster. * Xor them with the high bits of time which change slowly. @@ -84,7 +84,16 @@ isc_random_get(isc_uint32_t *val) * rand()'s lower bits are not random. * rand()'s upper bit is zero. */ +#if RAND_MAX >= 0xfffff + /* We have at least 20 bits. Use lower 16 excluding lower most 4 */ *val = ((rand() >> 4) & 0xffff) | ((rand() << 12) & 0xffff0000); +#elif RAND_MAX >= 0x7fff + /* We have at least 15 bits. Use lower 10/11 excluding lower most 4 */ + *val = ((rand() >> 4) & 0x000007ff) | ((rand() << 7) & 0x003ff800) | + ((rand() << 18) & 0xffc00000); +#else +#error RAND_MAX is too small +#endif #else *val = arc4random(); #endif @@ -92,13 +101,13 @@ isc_random_get(isc_uint32_t *val) isc_uint32_t isc_random_jitter(isc_uint32_t max, isc_uint32_t jitter) { + isc_uint32_t rnd; + REQUIRE(jitter < max); + if (jitter == 0) return (max); - else -#ifndef HAVE_ARC4RANDOM - return (max - rand() % jitter); -#else - return (max - arc4random() % jitter); -#endif + + isc_random_get(&rnd); + return (max - rnd % jitter); } diff --git a/lib/isc/sha2.c b/lib/isc/sha2.c index 70eea4f96700..ff19274837a6 100644 --- a/lib/isc/sha2.c +++ b/lib/isc/sha2.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2005-2007, 2009, 2010 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.2 2009/01/18 23:47:41 tbox Exp $ */ +/* $Id: sha2.c,v 1.13.332.4 2010/01/15 23:47:34 tbox Exp $ */ /* $FreeBSD$ */ /* $KAME: sha2.c,v 1.8 2001/11/08 01:07:52 itojun Exp $ */ @@ -415,6 +415,11 @@ isc_sha224_init(isc_sha224_t *context) { } void +isc_sha224_invalidate(isc_sha224_t *context) { + memset(context, 0, sizeof(isc_sha224_t)); +} + +void isc_sha224_update(isc_sha224_t *context, const isc_uint8_t* data, size_t len) { isc_sha256_update((isc_sha256_t *)context, data, len); } @@ -651,6 +656,11 @@ isc_sha256_transform(isc_sha256_t *context, const isc_uint32_t* data) { #endif /* ISC_SHA2_UNROLL_TRANSFORM */ void +isc_sha256_invalidate(isc_sha256_t *context) { + memset(context, 0, sizeof(isc_sha256_t)); +} + +void isc_sha256_update(isc_sha256_t *context, const isc_uint8_t *data, size_t len) { unsigned int freespace, usedspace; @@ -990,7 +1000,13 @@ isc_sha512_transform(isc_sha512_t *context, const isc_uint64_t* data) { #endif /* ISC_SHA2_UNROLL_TRANSFORM */ -void isc_sha512_update(isc_sha512_t *context, const isc_uint8_t *data, size_t len) { +void +isc_sha512_invalidate(isc_sha512_t *context) { + memset(context, 0, sizeof(isc_sha512_t)); +} + +void +isc_sha512_update(isc_sha512_t *context, const isc_uint8_t *data, size_t len) { unsigned int freespace, usedspace; if (len == 0U) { @@ -1164,6 +1180,11 @@ isc_sha384_init(isc_sha384_t *context) { } void +isc_sha384_invalidate(isc_sha384_t *context) { + memset(context, 0, sizeof(isc_sha384_t)); +} + +void isc_sha384_update(isc_sha384_t *context, const isc_uint8_t* data, size_t len) { isc_sha512_update((isc_sha512_t *)context, data, len); } diff --git a/lib/isc/unix/ifiter_getifaddrs.c b/lib/isc/unix/ifiter_getifaddrs.c index b576d4632fbb..87ef9ba7f500 100644 --- a/lib/isc/unix/ifiter_getifaddrs.c +++ b/lib/isc/unix/ifiter_getifaddrs.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2008 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007-2009 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 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: ifiter_getifaddrs.c,v 1.11 2008/03/20 23:47:00 tbox Exp $ */ +/* $Id: ifiter_getifaddrs.c,v 1.11.120.2 2009/09/24 23:47:34 tbox Exp $ */ /*! \file * \brief @@ -181,7 +181,7 @@ internal_current(isc_interfaceiter_t *iter) { ifa->ifa_name); if (ifa->ifa_dstaddr != NULL && - (iter->current.flags & IFF_POINTOPOINT) != 0) + (iter->current.flags & INTERFACE_F_POINTTOPOINT) != 0) get_addr(family, &iter->current.dstaddress, ifa->ifa_dstaddr, ifa->ifa_name); diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index d09fe51ab57c..004a038a3a88 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2010 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.8 2009/04/18 01:29:26 jinmei Exp $ */ +/* $Id: socket.c,v 1.308.12.12 2010/01/31 23:47:31 tbox Exp $ */ /*! \file */ @@ -1520,12 +1520,22 @@ doio_recv(isc_socket_t *sock, isc_socketevent_t *dev) { } /* - * On TCP, zero length reads indicate EOF, while on - * UDP, zero length reads are perfectly valid, although - * strange. + * On TCP and UNIX sockets, zero length reads indicate EOF, + * while on UDP sockets, zero length reads are perfectly valid, + * although strange. */ - if ((sock->type == isc_sockettype_tcp) && (cc == 0)) - return (DOIO_EOF); + switch (sock->type) { + case isc_sockettype_tcp: + case isc_sockettype_unix: + if (cc == 0) + return (DOIO_EOF); + break; + case isc_sockettype_udp: + break; + case isc_sockettype_fdwatch: + default: + INSIST(0); + } if (sock->type == isc_sockettype_udp) { dev->address.length = msghdr.msg_namelen; @@ -3645,7 +3655,7 @@ setup_watcher(isc_mem_t *mctx, isc_socketmgr_t *manager) { manager->maxsocks); if (manager->fdpollinfo == NULL) { isc_mem_put(mctx, manager->events, - sizeof(pollinfo_t) * manager->maxsocks); + sizeof(struct pollfd) * manager->nevents); return (ISC_R_NOMEMORY); } memset(manager->fdpollinfo, 0, sizeof(pollinfo_t) * manager->maxsocks); @@ -4851,6 +4861,7 @@ isc_socket_connect(isc_socket_t *sock, isc_sockaddr_t *addr, isc_socketmgr_t *manager; int cc; char strbuf[ISC_STRERRORSIZE]; + char addrbuf[ISC_SOCKADDR_FORMATSIZE]; REQUIRE(VALID_SOCKET(sock)); REQUIRE(addr != NULL); @@ -4919,7 +4930,9 @@ isc_socket_connect(isc_socket_t *sock, isc_sockaddr_t *addr, sock->connected = 0; isc__strerror(errno, strbuf, sizeof(strbuf)); - UNEXPECTED_ERROR(__FILE__, __LINE__, "%d/%s", errno, strbuf); + isc_sockaddr_format(addr, addrbuf, sizeof(addrbuf)); + UNEXPECTED_ERROR(__FILE__, __LINE__, "connect(%s) %d/%s", + addrbuf, errno, strbuf); UNLOCK(&sock->lock); inc_stats(sock->manager->stats, |
