From: wessels <> Date: Thu, 14 May 1998 04:59:44 +0000 (+0000) Subject: Must memcpy() tmp_keys to ensure alignment! X-Git-Tag: SQUID_3_0_PRE1~3323 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=13c31e7244d8ffb830e4b05897b09bae480e85f3;p=thirdparty%2Fsquid.git Must memcpy() tmp_keys to ensure alignment! --- diff --git a/src/CacheDigest.cc b/src/CacheDigest.cc index 6336a07c9c..08863c5683 100644 --- a/src/CacheDigest.cc +++ b/src/CacheDigest.cc @@ -1,6 +1,6 @@ /* - * $Id: CacheDigest.cc,v 1.19 1998/05/13 21:16:30 wessels Exp $ + * $Id: CacheDigest.cc,v 1.20 1998/05/13 22:59:44 wessels Exp $ * * DEBUG: section 70 Cache Digest * AUTHOR: Alex Rousskov @@ -40,7 +40,7 @@ typedef struct { } CacheDigestStats; /* local functions */ -static void cacheDigestHashKey(const CacheDigest * cd, const void * key); +static void cacheDigestHashKey(const CacheDigest * cd, const cache_key * key); /* static array used by cacheDigestHashKey for optimization purposes */ static u_num32 hashed_keys[4]; @@ -320,10 +320,12 @@ cacheDigestHashKey(const CacheDigest * cd, const cache_key * key) #endif static void -cacheDigestHashKey(const CacheDigest * cd, const void *key) +cacheDigestHashKey(const CacheDigest * cd, const cache_key *key) { const unsigned int bit_count = cd->mask_size * 8; - const unsigned int *tmp_keys = key; + unsigned int tmp_keys[4]; + /* we must memcpy to ensure alignment */ + xmemcpy(tmp_keys, key, sizeof(tmp_keys)); hashed_keys[0] = htonl(tmp_keys[0]) % bit_count; hashed_keys[1] = htonl(tmp_keys[1]) % bit_count; hashed_keys[2] = htonl(tmp_keys[2]) % bit_count;