pike.git / src / stralloc.c

version» Context lines:

pike.git/src/stralloc.c:69:   #else   #define LOCK_BUCKET(HVAL)   #define UNLOCK_BUCKET(HVAL)   #endif /* PIKE_RUN_UNLOCKED */      #define BEGIN_HASH_SIZE 1024      static unsigned int hash_prefix_len=64;   static unsigned int need_more_hash_prefix_depth=0;    - /* Force a new hashkey to be generated early during init. */ - static unsigned int need_new_hashkey_depth=0xffff; + static unsigned int need_new_hashkey_depth=0;   static size_t hashkey = 0;      static unsigned INT32 htable_size=0;   static unsigned int hashprimes_entry=0;   static struct pike_string **base_table=0;   static unsigned INT32 num_strings=0;   PMOD_EXPORT struct pike_string *empty_pike_string = 0;      /*** Main string hash function ***/   
pike.git/src/stralloc.c:741:    * more than 16 strings. This ought to    * suffice to alleviate the #hashdos vulnerability.    *    * /grubba    */       /* This could in theory have a pretty ugly complexity    * /Hubbe    */    +  if (need_new_hashkey_depth > 128) { +  /* A simple mixing function. */ +  hashkey ^= (hashkey << 5) ^ (current_time.tv_sec ^ current_time.tv_usec); +  need_new_hashkey_depth = 0; +  } +    #ifdef PIKE_RUN_UNLOCKED    mt_lock(bucket_locks);    if(need_more_hash_prefix_depth <= 4)    {    /* Someone got here before us */    mt_lock(bucket_locks);    return;    }    for(h=1;h<BUCKET_LOCKS;h++) mt_lock(bucket_locks+h);   #endif    -  /* A simple mixing function. */ -  hashkey ^= (hashkey << 5) ^ (current_time.tv_sec ^ current_time.tv_usec); -  +     if (need_more_hash_prefix_depth > 4)    {    hash_prefix_len=hash_prefix_len*2;   #if 0    fprintf(stderr, "Doubling hash_prefix_len to %d and rehashing\n",    hash_prefix_len);   #endif /* 0 */    }    /* NOTE: No need to update to the correct values, since that will    * be done on demand.    */ -  need_new_hashkey_depth = 0; +     need_more_hash_prefix_depth=0;       for(h=0;h<htable_size;h++)    {    struct pike_string *tmp=base_table[h];    base_table[h]=0;    while(tmp)    {    size_t h2;    struct pike_string *tmp2=tmp; /* First unlink */