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

Re: How to detect hash randomization?

Thread Previous | Thread Next
Jim Cromie
September 13, 2003 12:38
Re: How to detect hash randomization?
Message ID:
Elizabeth Mattijsen wrote:

> Hmmm... there is also a run-time component to this check, namely 
> whether or not PERL_HASH_SEED is set or not.  So that would imply some 
> more magic in the tied %Config hash...  ;-(

approximately, run-time is all that matters,
tho below checks Config{ccflags} to invert result when
compiled with "-DUSE_HASH_SEED_EXPLICIT".


use Config;

sub  are_hashes_randomized {
    return 0 if $] < 5.008001;
        not defined $ENV{PERL_HASH_SEED}
         xor $Config{ccflags} =~ m/USE_HASH_SEED_EXPLICIT/;

print "conf: $Config{ccflags}\n";
print "randomized: ", are_hashes_randomized(), "\n";


above is not quite right, it doesnt honor the non-numeric string 
comments in perlrun.
Removing 'defined' check from above looks to fix that, but im leaving it 
as 'approximate'.
There may be other factors im unaware of..

> Liz
> .

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About