diff options
Diffstat (limited to 'utils/imxtools')
-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) |