You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/08/17 07:11:50 UTC

[GitHub] [incubator-nuttx-apps] pkarashchenko commented on a diff in pull request #1282: apps: Fix bug by calling getrandom

pkarashchenko commented on code in PR #1282:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1282#discussion_r947529603


##########
fsutils/mkgpt/mkgpt.c:
##########
@@ -128,12 +129,12 @@ static const uint8_t g_partition_type_swap[16] =
 
 static void get_uuid(FAR uint8_t *uuid)
 {
-  int fd;
-  fd = open("/dev/urandom", O_RDONLY);
-  if (fd > 0)
+  /* call getrandom to read  /dev/urandom */
+
+  if (getrandom(uuid, 16, 1) < 0)

Review Comment:
   ```suggestion
     if (getrandom(uuid, 16, GRND_NONBLOCK) < 0)
   ```



##########
fsutils/mkgpt/mkgpt.c:
##########
@@ -128,12 +129,12 @@ static const uint8_t g_partition_type_swap[16] =
 
 static void get_uuid(FAR uint8_t *uuid)
 {
-  int fd;
-  fd = open("/dev/urandom", O_RDONLY);
-  if (fd > 0)
+  /* call getrandom to read  /dev/urandom */
+
+  if (getrandom(uuid, 16, 1) < 0)

Review Comment:
   But current code is different from the original one that was a blocking read.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org