diff options
| author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2012-02-08 21:23:38 +0100 |
|---|---|---|
| committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2012-02-08 21:28:20 +0100 |
| commit | d23d164b85c5516126d77ab7038d55cebcdb6687 (patch) | |
| tree | 5915ce1b03da5a2ead84ad1e9dd66d5b88e9154a | |
| parent | 1ab9d14c77adc241ff1b126f216dbac8dd34e3fc (diff) | |
| download | rockbox-d23d164b85c5516126d77ab7038d55cebcdb6687.zip rockbox-d23d164b85c5516126d77ab7038d55cebcdb6687.tar.gz rockbox-d23d164b85c5516126d77ab7038d55cebcdb6687.tar.bz2 rockbox-d23d164b85c5516126d77ab7038d55cebcdb6687.tar.xz | |
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
| -rw-r--r-- | utils/imxtools/misc.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/utils/imxtools/misc.c b/utils/imxtools/misc.c index 7271ca8..abbffbd 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) |