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 @@ ...@@ -8,6 +8,7 @@
*.trs *.trs
*.core *.core
.tmp.* .tmp.*
*.exe
# Generated by `autoreconf` # Generated by `autoreconf`
config/ config/
......
...@@ -42,17 +42,22 @@ asn_random_between(intmax_t lb, intmax_t rb) { ...@@ -42,17 +42,22 @@ asn_random_between(intmax_t lb, intmax_t rb) {
uintmax_t range = asn__intmax_range(lb, rb); uintmax_t range = asn__intmax_range(lb, rb);
uintmax_t value = 0; uintmax_t value = 0;
uintmax_t got_entropy = 0; uintmax_t got_entropy = 0;
(void)intmax_max; (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); assert(range < intmax_max);
for(; got_entropy < range;) { for(; got_entropy < range;) {
got_entropy = (got_entropy << 24) | 0xffffff; got_entropy = (got_entropy << 24) | max;
#ifdef HAVE_RANDOM #ifdef HAVE_RANDOM
value = (value << 24) | (random() % 0xffffff); value = (value << 24) | (random() % max);
#else #else
value = (value << 24) | (rand() % 0xffffff); value = (value << 24) | (rand() % max);
#endif #endif
} }
......
...@@ -70,6 +70,11 @@ static void junk_bytes_with_probability(uint8_t *, size_t, double prob); ...@@ -70,6 +70,11 @@ static void junk_bytes_with_probability(uint8_t *, size_t, double prob);
#define RANDOPT "R:" #define RANDOPT "R:"
static ssize_t random_max_size = 0; /* Size of the random data */ 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__)) #if !defined(__FreeBSD__) && !(defined(__APPLE__) && defined(__MACH__))
static void static void
srandomdev(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