Currently xgetrandom always uses the fallback path even if getrandom returns 
success.

Patrick
>From 43d8947b9448a0212198551acd6a0ac6a01a0486 Mon Sep 17 00:00:00 2001
From: Patrick Oppenlander <patrick.oppenlan...@gmail.com>
Date: Wed, 18 Jul 2018 15:09:13 +1000
Subject: [PATCH] xgetrandom: use getrandom result if it succeeds

---
 lib/portability.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/portability.c b/lib/portability.c
index 1415141..2ba3d29 100644
--- a/lib/portability.c
+++ b/lib/portability.c
@@ -35,8 +35,8 @@ void xgetrandom(void *buf, unsigned buflen, unsigned flags)
   int fd;
 
 #if CFG_TOYBOX_GETRANDOM
-  if (buflen != getrandom(buf, buflen, flags))
-    if (!CFG_TOYBOX_ON_ANDROID || errno!=ENOSYS) perror_exit("getrandom");
+  if (buflen == getrandom(buf, buflen, flags)) return;
+  if (!CFG_TOYBOX_ON_ANDROID || errno!=ENOSYS) perror_exit("getrandom");
 #endif
 
   fd = xopen(flags ? "/dev/random" : "/dev/urandom", O_RDONLY);
-- 
2.18.0

_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to