chunk: Rename hash key variable to avoid conflicts with function arguments
This commit is contained in:
parent
d3ca9fcda4
commit
a6723ee3e0
|
@ -930,7 +930,7 @@ uint64_t chunk_mac(chunk_t chunk, u_char *key)
|
|||
/**
|
||||
* Secret key allocated randomly with chunk_hash_seed().
|
||||
*/
|
||||
static u_char key[16] = {};
|
||||
static u_char hash_key[16] = {};
|
||||
|
||||
/**
|
||||
* Static key used in case predictable hash values are required.
|
||||
|
@ -957,9 +957,9 @@ void chunk_hash_seed()
|
|||
fd = open("/dev/urandom", O_RDONLY);
|
||||
if (fd >= 0)
|
||||
{
|
||||
while (done < sizeof(key))
|
||||
while (done < sizeof(hash_key))
|
||||
{
|
||||
len = read(fd, key + done, sizeof(key) - done);
|
||||
len = read(fd, hash_key + done, sizeof(hash_key) - done);
|
||||
if (len < 0)
|
||||
{
|
||||
break;
|
||||
|
@ -969,12 +969,12 @@ void chunk_hash_seed()
|
|||
close(fd);
|
||||
}
|
||||
/* on error we use random() to generate the key (better than nothing) */
|
||||
if (done < sizeof(key))
|
||||
if (done < sizeof(hash_key))
|
||||
{
|
||||
srandom(time(NULL) + getpid());
|
||||
for (; done < sizeof(key); done++)
|
||||
for (; done < sizeof(hash_key); done++)
|
||||
{
|
||||
key[done] = (u_char)random();
|
||||
hash_key[done] = (u_char)random();
|
||||
}
|
||||
}
|
||||
seeded = TRUE;
|
||||
|
@ -986,7 +986,7 @@ void chunk_hash_seed()
|
|||
uint32_t chunk_hash_inc(chunk_t chunk, uint32_t hash)
|
||||
{
|
||||
/* we could use a mac of the previous hash, but this is faster */
|
||||
return chunk_mac_inc(chunk, key, ((uint64_t)hash) << 32 | hash);
|
||||
return chunk_mac_inc(chunk, hash_key, ((uint64_t)hash) << 32 | hash);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -994,7 +994,7 @@ uint32_t chunk_hash_inc(chunk_t chunk, uint32_t hash)
|
|||
*/
|
||||
uint32_t chunk_hash(chunk_t chunk)
|
||||
{
|
||||
return chunk_mac(chunk, key);
|
||||
return chunk_mac(chunk, hash_key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue