aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPatrick Oppenlander <patrick.oppenlander@gmail.com>2018-07-18 15:09:13 +1000
committerRob Landley <rob@landley.net>2018-08-03 16:13:47 -0500
commitdb017ea49b316d7d95a2641650648cbd6bbde03e (patch)
tree6dfbd7309c857798b57e265c57729f3b54fae819 /lib
parentb51fcf8e7946aa3a059634804bd426f1b6fab571 (diff)
downloadtoybox-db017ea49b316d7d95a2641650648cbd6bbde03e.tar.gz
xgetrandom: use getrandom result if it succeeds
Diffstat (limited to 'lib')
-rw-r--r--lib/portability.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/portability.c b/lib/portability.c
index 1415141f..2ba3d29f 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);