From d23d164b85c5516126d77ab7038d55cebcdb6687 Mon Sep 17 00:00:00 2001 From: Dominik Riebeling Date: Wed, 8 Feb 2012 21:23:38 +0100 Subject: imxtools: use rand() instead of /dev/random. On Windows /dev/random does not exist, so trying to open it will fail. Replace it with rand() which is available on all supported platforms and sufficient. Fixes mkimxboot not working, as well as Rockbox Utility "crashing" (which is in fact its error handler calling exit(), thus terminating Rockbox Utility) on Windows. Change-Id: Ia164f937f329877e8f80f473f27be8c5df2a0a68 --- utils/imxtools/misc.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/utils/imxtools/misc.c b/utils/imxtools/misc.c index 7271ca8ab7..abbffbd5ae 100644 --- a/utils/imxtools/misc.c +++ b/utils/imxtools/misc.c @@ -39,12 +39,10 @@ void *memdup(const void *p, size_t len) void generate_random_data(void *buf, size_t sz) { - FILE *rand_fd = fopen("/dev/urandom", "rb"); - if(rand_fd == NULL) - bugp("failed to open /dev/urandom"); - if(fread(buf, 1, sz, rand_fd) != sz) - bugp("failed to read /dev/urandom"); - fclose(rand_fd); + int i = 0; + unsigned char* p = (unsigned char*)buf; + while(i++ < sz) + *p++ = rand(); } void *xmalloc(size_t s) -- cgit v1.2.3