Skip to content

Commit d23d164

Browse files
committed
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
1 parent 1ab9d14 commit d23d164

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

utils/imxtools/misc.c

+4-6
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,10 @@ void *memdup(const void *p, size_t len)
3939

4040
void generate_random_data(void *buf, size_t sz)
4141
{
42-
FILE *rand_fd = fopen("/dev/urandom", "rb");
43-
if(rand_fd == NULL)
44-
bugp("failed to open /dev/urandom");
45-
if(fread(buf, 1, sz, rand_fd) != sz)
46-
bugp("failed to read /dev/urandom");
47-
fclose(rand_fd);
42+
int i = 0;
43+
unsigned char* p = (unsigned char*)buf;
44+
while(i++ < sz)
45+
*p++ = rand();
4846
}
4947

5048
void *xmalloc(size_t s)

0 commit comments

Comments
 (0)