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.tar.gz rockbox-d23d164b85c5516126d77ab7038d55cebcdb6687.zip |
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 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) | |||
39 | 39 | ||
40 | void generate_random_data(void *buf, size_t sz) | 40 | void generate_random_data(void *buf, size_t sz) |
41 | { | 41 | { |
42 | FILE *rand_fd = fopen("/dev/urandom", "rb"); | 42 | int i = 0; |
43 | if(rand_fd == NULL) | 43 | unsigned char* p = (unsigned char*)buf; |
44 | bugp("failed to open /dev/urandom"); | 44 | while(i++ < sz) |
45 | if(fread(buf, 1, sz, rand_fd) != sz) | 45 | *p++ = rand(); |
46 | bugp("failed to read /dev/urandom"); | ||
47 | fclose(rand_fd); | ||
48 | } | 46 | } |
49 | 47 | ||
50 | void *xmalloc(size_t s) | 48 | void *xmalloc(size_t s) |