Use a prime that fits 32bits on 32bit platforms

Bug reported by Yann Droneaud, thanks!
https://bugzilla.redhat.com/show_bug.cgi?id=1197087#c21
This commit is contained in:
Sebastian Pipping 2016-03-21 20:05:27 +01:00
parent ca523deca4
commit f627ff74d6

View file

@ -709,9 +709,16 @@ static unsigned long
generate_hash_secret_salt(XML_Parser parser)
{
/* Process ID is 0 bits entropy if attacker has local access
* XML_Parser address is few bits of entropy if attacker has local access
* Factor is 2^61-1 (Mersenne prime M61) */
return (gather_time_entropy() ^ getpid() ^ (unsigned long)parser) * 2305843009213693951;
* XML_Parser address is few bits of entropy if attacker has local access */
const unsigned long entropy =
gather_time_entropy() ^ getpid() ^ (unsigned long)parser;
/* Factors are 2^31-1 and 2^61-1 (Mersenne primes M31 and M61) */
if (sizeof(unsigned long) == 4) {
return entropy * 2147483647;
} else {
return entropy * 2305843009213693951;
}
}
static XML_Bool /* only valid for root parser */