From 4793e6f30f37084e9518b1ad1b73274642c1e72f Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 6 Dec 2016 04:43:48 +0000 Subject: switching hash removal * st.h (struct st_hash_type): Remove strong_hash. (struct st_table): Remove inside_rebuild_p and curr_hash. * st.c (do_hash): Use type->hash instead of curr_hash. (make_tab_empty): Remove setting up curr_hash. (st_init_table_with_size): Remove setting up inside_rebuild_p. (rebuild_table): Remove clearing inside_rebuild_p. (reset_entry_hashes, HIT_THRESHOULD_FOR_STRONG_HASH): Remove code recognizing a denial attack and switching to strong hash. * hash.c (rb_dbl_long_hash, rb_objid_hash, rb_ident_hash): Use rb_hash_start to randomize the hash. (str_seed): Remove. (any_hash): Remove strong_p and use always rb_str_hash for strings. (any_hash_weak, rb_any_hash_weak): Remove. (st_hash_type objhash): Remove rb_any_hash_weak. based on the patch by Vladimir N Makarov at [ruby-core:78490]. [Bug #13002] * test/ruby/test_hash.rb (test_wrapper): objects other than special constants should be able to be wrapped. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- include/ruby/st.h | 9 --------- 1 file changed, 9 deletions(-) (limited to 'include') diff --git a/include/ruby/st.h b/include/ruby/st.h index ede75458c4..41f2913b80 100644 --- a/include/ruby/st.h +++ b/include/ruby/st.h @@ -61,11 +61,6 @@ typedef char st_check_for_sizeof_st_index_t[SIZEOF_VOIDP == (int)sizeof(st_index struct st_hash_type { int (*compare)(ANYARGS /*st_data_t, st_data_t*/); /* st_compare_func* */ st_index_t (*hash)(ANYARGS /*st_data_t*/); /* st_hash_func* */ - /* The following is an optional func for stronger hash. When we - have many different keys with the same hash we can switch to - use it to prevent a denial attack with usage of hash table - collisions. */ - st_index_t (*strong_hash)(ANYARGS /*st_data_t*/); }; #if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR) && defined(HAVE_BUILTIN___BUILTIN_TYPES_COMPATIBLE_P) @@ -82,12 +77,8 @@ struct st_table_entry; /* defined in st.c */ struct st_table { /* Cached features of the table -- see st.c for more details. */ unsigned char entry_power, bin_power, size_ind; - /* True when we are rebuilding the table. */ - unsigned char inside_rebuild_p; /* How many times the table was rebuilt. */ unsigned int rebuilds_num; - /* Currently used hash function. */ - st_index_t (*curr_hash)(ANYARGS /*st_data_t*/); const struct st_hash_type *type; /* Number of entries currently in the table. */ st_index_t num_entries; -- cgit v1.2.3