Unverified Commit b2273e1e authored by Kent Kostelac's avatar Kent Kostelac Committed by GitHub

Merge branch 'mouse07410:vlm_master' into develop

parents 62842afb 208d9edd
......@@ -8,6 +8,7 @@
*.trs
*.core
.tmp.*
*.exe
# Generated by `autoreconf`
config/
......
......@@ -42,17 +42,22 @@ asn_random_between(intmax_t lb, intmax_t rb) {
uintmax_t range = asn__intmax_range(lb, rb);
uintmax_t value = 0;
uintmax_t got_entropy = 0;
(void)intmax_max;
assert(RAND_MAX > 0xffffff); /* Seen 7ffffffd! */
int max = 0xffffff;
#ifdef __WIN32__
max = RAND_MAX-1;
#endif
assert(RAND_MAX > max); /* Seen 7ffffffd! */
assert(range < intmax_max);
for(; got_entropy < range;) {
got_entropy = (got_entropy << 24) | 0xffffff;
got_entropy = (got_entropy << 24) | max;
#ifdef HAVE_RANDOM
value = (value << 24) | (random() % 0xffffff);
value = (value << 24) | (random() % max);
#else
value = (value << 24) | (rand() % 0xffffff);
value = (value << 24) | (rand() % max);
#endif
}
......
......@@ -70,6 +70,11 @@ static void junk_bytes_with_probability(uint8_t *, size_t, double prob);
#define RANDOPT "R:"
static ssize_t random_max_size = 0; /* Size of the random data */
#if defined(__WIN32__) && defined(JUNKTEST)
#define random rand
#define srandom srand
#endif
#if !defined(__FreeBSD__) && !(defined(__APPLE__) && defined(__MACH__))
static void
srandomdev(void) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment