Fix for hash table collision attack. We simply randomize hash table initialization value at startup time.

This commit is contained in:
antirez
2012-01-21 23:05:32 +01:00
parent 447ebf3bc7
commit a48c8d873b
4 changed files with 22 additions and 4 deletions

View File

@ -1080,8 +1080,6 @@ void initServer() {
scriptingInit();
slowlogInit();
bioInit();
srand(time(NULL)^getpid());
}
/* Populates the Redis Command Table starting from the hard coded list
@ -1959,9 +1957,15 @@ void setupSignalHandlers(void) {
int main(int argc, char **argv) {
long long start;
struct timeval tv;
/* We need to initialize our libraries, and the server. */
zmalloc_enable_thread_safeness();
srand(time(NULL)^getpid());
gettimeofday(&tv,NULL);
dictSetHashFunctionSeed(tv.tv_sec^tv.tv_usec^getpid());
initServerConfig();
if (argc >= 2) {
int j = 1; /* First option to parse in argv[] */
sds options = sdsempty();