forked from len0rd/rockbox
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
This commit is contained in:
parent
1ab9d14c77
commit
d23d164b85
1 changed files with 4 additions and 6 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue