mirror of
https://github.com/NLnetLabs/unbound.git
synced 2026-01-28 01:19:19 -05:00
Fix mingw ID randomness from 8 to 16 bits.
git-svn-id: file:///svn/unbound/trunk@1717 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
7b03403efd
commit
73da11fe07
2 changed files with 9 additions and 1 deletions
|
|
@ -2,6 +2,8 @@
|
|||
- Fix for crash at start on windows.
|
||||
- tag for release 1.3.2.
|
||||
- trunk has version 1.3.3.
|
||||
- Fix for ID bits on windows to use all 16. RAND_MAX was not
|
||||
defined like you'd expect on mingw.
|
||||
|
||||
9 July 2009: Wouter
|
||||
- tag for release 1.3.1.
|
||||
|
|
|
|||
|
|
@ -78,6 +78,12 @@ struct ub_randstate {
|
|||
/** Size of key to use */
|
||||
#define SEED_SIZE 20
|
||||
|
||||
/**
|
||||
* Max random value. Similar to RAND_MAX, but more portable
|
||||
* (mingw uses only 15 bits random).
|
||||
*/
|
||||
#define MAX_VALUE 0x7fffffff
|
||||
|
||||
/** Number of bytes to reseed after */
|
||||
#define REKEY_BYTES (1 << 24)
|
||||
|
||||
|
|
@ -168,7 +174,7 @@ ub_random(struct ub_randstate* s)
|
|||
RC4(&s->rc4, sizeof(r),
|
||||
(unsigned char *)&r, (unsigned char *)&r);
|
||||
s->rc4_ready -= sizeof(r);
|
||||
return (long int)((r) % (((unsigned)RAND_MAX + 1)));
|
||||
return (long int)((r) % (((unsigned)MAX_VALUE + 1)));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Reference in a new issue