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

Re: How to detect hash randomization?

Thread Previous | Thread Next
From:
Jim Cromie
Date:
September 13, 2003 12:38
Subject:
Re: How to detect hash randomization?
Message ID:
3F637232.1060001@divsol.com
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".

#__START__

use Config;

sub  are_hashes_randomized {
    return 0 if $] < 5.008001;
    return
        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";

__END__

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
>
> .
>
--jimc


Thread Previous | 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