develooper Front page | perl.perl5.porters | Postings from November 2003

[patch t/op/hash.t] extending the hash attack test

Thread Next
From:
Stas Bekman
Date:
November 4, 2003 14:32
Subject:
[patch t/op/hash.t] extending the hash attack test
Message ID:
3FA82925.7020703@stason.org
Here is the patch that extends t/op/hash.t to use dynamically generated keys 
that trigger an attack on any prepopulated or empty hash, which is also 
suitable for stashes (you can't use \0 in stash keys). Here is the verbose output:

/home/stas/perl.org/perl-5.8.2/t> ./TEST -v op/hash.t
t/op/hash....1..5
ok 1 - hash doesn't start with rehash flag on
ok 2 - 10 entries doesn't trigger rehash
ok 3 - 20 entries triggers rehash
ok 4 - starting with pre-populated non-pathalogical hash (rehash flag if off)
# using mask: 511 (9)
#  1:    gg, 1795449344
#  2:    ne, 1008598016
#  3:    qz, 3246326784
#  4:    sp, 3095851008
#  5:   abp, 2976327680
#  6:   bmt, 1750066688
#  7:   bqy, 3736395776
#  8:   bsg, 2078675968
#  9:   bvh, 1273085440
# 10:   cfy, 2884105728
# 11:   elg,  115318272
# 12:   fra,     112128
# 13:   fvi, 2512840192
# 14:   hkj, 2544594944
# 15:   ifc, 2757291520
# 16:   ila, 2864112128
ok 5 - 16 colliding into the same bucket keys are triggerring rehash
ok
All tests successful.
u=0.04  s=0  cu=0.3  cs=0  scripts=1  tests=5

Tels has come up with an even faster implementation of PERL_HASH in perl, so 
I'm using his function.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About