diff options
Diffstat (limited to 'lib/isc/hash.c')
-rw-r--r-- | lib/isc/hash.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/isc/hash.c b/lib/isc/hash.c index f1d68c7700f5..f70e7943312d 100644 --- a/lib/isc/hash.c +++ b/lib/isc/hash.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2007, 2009, 2013, 2014 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -94,7 +94,7 @@ struct isc_hash { isc_boolean_t initialized; isc_refcount_t refcnt; isc_entropy_t *entropy; /*%< entropy source */ - unsigned int limit; /*%< upper limit of key length */ + size_t limit; /*%< upper limit of key length */ size_t vectorlen; /*%< size of the vector below */ hash_random_t *rndvector; /*%< random vector for universal hashing */ }; @@ -140,7 +140,7 @@ static unsigned char maptolower[] = { isc_result_t isc_hash_ctxcreate(isc_mem_t *mctx, isc_entropy_t *entropy, - unsigned int limit, isc_hash_t **hctxp) + size_t limit, isc_hash_t **hctxp) { isc_result_t result; isc_hash_t *hctx; @@ -250,7 +250,8 @@ isc_hash_ctxinit(isc_hash_t *hctx) { isc_result_t result; result = isc_entropy_getdata(hctx->entropy, - hctx->rndvector, hctx->vectorlen, + hctx->rndvector, + (unsigned int)hctx->vectorlen, NULL, 0); INSIST(result == ISC_R_SUCCESS); #else @@ -258,7 +259,7 @@ isc_hash_ctxinit(isc_hash_t *hctx) { #endif } else { isc_uint32_t pr; - unsigned int i, copylen; + size_t i, copylen; unsigned char *p; p = (unsigned char *)hctx->rndvector; @@ -269,7 +270,7 @@ isc_hash_ctxinit(isc_hash_t *hctx) { else copylen = hctx->vectorlen - i; - memcpy(p, &pr, copylen); + memmove(p, &pr, copylen); } INSIST(p == (unsigned char *)hctx->rndvector + hctx->vectorlen); @@ -323,9 +324,9 @@ destroy(isc_hash_t **hctxp) { DESTROYLOCK(&hctx->lock); - memcpy(canary0, hctx + 1, sizeof(canary0)); + memmove(canary0, hctx + 1, sizeof(canary0)); memset(hctx, 0, sizeof(isc_hash_t)); - memcpy(canary1, hctx + 1, sizeof(canary1)); + 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); |