aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2018-07-06 19:40:35 -0500
committerRob Landley <rob@landley.net>2018-07-06 19:40:35 -0500
commitd2e317a622c672109ed25176044a3920a1167466 (patch)
tree15f4aed962b4124d07297954727c74b9222e3621
parentff2d528a0a6943bd4247f3c122c145a5b19f0387 (diff)
downloadtoybox-d2e317a622c672109ed25176044a3920a1167466.tar.gz
Bionic ships newer libc with older kernels, so Android needs to fallback at
runtime for ENOSYS.
-rw-r--r--lib/portability.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/portability.c b/lib/portability.c
index c42a052e..80ca8c9a 100644
--- a/lib/portability.c
+++ b/lib/portability.c
@@ -32,13 +32,16 @@ pid_t xfork(void)
void xgetrandom(void *buf, unsigned buflen, unsigned flags)
{
+ int fd;
+
#if CFG_TOYBOX_GETRANDOM
- if (buflen != getrandom(buf, buflen, flags)) perror_exit("getrandom");
-#else
- int fd = xopen(flags ? "/dev/random" : "/dev/urandom", O_RDONLY);
+ if (buflen != getrandom(buf, buflen, flags))
+ if (!CFG_TOYBOX_ANDROID || errno!=ENOSYS) perror_exit("getrandom");
+#endif
+
+ fd = xopen(flags ? "/dev/random" : "/dev/urandom", O_RDONLY);
xreadall(fd, buf, buflen);
close(fd);
-#endif
}
#if defined(__APPLE__)