diff options
author | Tony Cook <tony@develop-help.com> | 2016-12-08 14:14:11 +1100 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2017-01-09 10:12:24 +1100 |
commit | 95309d6ba0f3066cdc457f5fb82ab4e6e01a2c98 (patch) | |
tree | c8f985d9927837551a59f3ed0a1cd99a23d79313 /util.c | |
parent | 33874d2ee2164003685ac15eb106c9356ccf586e (diff) | |
download | perl-95309d6ba0f3066cdc457f5fb82ab4e6e01a2c98.tar.gz |
add build options to disable the PERL_HASH* and PERL_PERTURB_KEYS env vars
These variables either control or reveal information used in perl's
hash implementation that a careful user may not want controlled or
exposed.
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -4712,20 +4712,23 @@ Perl_seed(pTHX) void Perl_get_hash_seed(pTHX_ unsigned char * const seed_buffer) { +#ifndef NO_PERL_HASH_ENV const char *env_pv; +#endif unsigned long i; PERL_ARGS_ASSERT_GET_HASH_SEED; +#ifndef NO_PERL_HASH_ENV env_pv= PerlEnv_getenv("PERL_HASH_SEED"); if ( env_pv ) -#ifndef USE_HASH_SEED_EXPLICIT +# ifndef USE_HASH_SEED_EXPLICIT { /* ignore leading spaces */ while (isSPACE(*env_pv)) env_pv++; -#ifdef USE_PERL_PERTURB_KEYS +# ifdef USE_PERL_PERTURB_KEYS /* if they set it to "0" we disable key traversal randomization completely */ if (strEQ(env_pv,"0")) { PL_hash_rand_bits_enabled= 0; @@ -4733,7 +4736,7 @@ Perl_get_hash_seed(pTHX_ unsigned char * const seed_buffer) /* otherwise switch to deterministic mode */ PL_hash_rand_bits_enabled= 2; } -#endif +# endif /* ignore a leading 0x... if it is there */ if (env_pv[0] == '0' && env_pv[1] == 'x') env_pv += 2; @@ -4755,6 +4758,7 @@ Perl_get_hash_seed(pTHX_ unsigned char * const seed_buffer) /* should we warn about insufficient hex? */ } else +# endif #endif { (void)seedDrand01((Rand_seed_t)seed()); @@ -4774,6 +4778,7 @@ Perl_get_hash_seed(pTHX_ unsigned char * const seed_buffer) PL_hash_rand_bits = ROTL_UV(PL_hash_rand_bits,8); } } +# ifndef NO_PERL_HASH_ENV env_pv= PerlEnv_getenv("PERL_PERTURB_KEYS"); if (env_pv) { if (strEQ(env_pv,"0") || strEQ(env_pv,"NO")) { @@ -4786,6 +4791,7 @@ Perl_get_hash_seed(pTHX_ unsigned char * const seed_buffer) Perl_warn(aTHX_ "perl: warning: strange setting in '$ENV{PERL_PERTURB_KEYS}': '%s'\n", env_pv); } } +# endif #endif } |