apps: Fix bug by calling getrandom
Signed-off-by: weizihan <weizihan@xiaomi.com>
This commit is contained in:
parent
8fe295de32
commit
c4972d4721
@ -31,6 +31,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <sys/random.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
@ -128,12 +129,12 @@ static const uint8_t g_partition_type_swap[16] =
|
|||||||
|
|
||||||
static void get_uuid(FAR uint8_t *uuid)
|
static void get_uuid(FAR uint8_t *uuid)
|
||||||
{
|
{
|
||||||
int fd;
|
/* call getrandom to read /dev/urandom */
|
||||||
fd = open("/dev/urandom", O_RDONLY);
|
|
||||||
if (fd > 0)
|
if (getrandom(uuid, 16, 0) < 0)
|
||||||
{
|
{
|
||||||
read(fd, uuid, 16);
|
fprintf(stderr, "error read primary partition table\n");
|
||||||
close(fd);
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user