>having just this evening updated Android to the current arc4random
>(https://android-review.googlesource.com/#/c/99052/), i was confused
>by the single use of explicit_bzero amongst the many calls to memset
>in the same file. as for portability, Linux requires MAP_PRIVATE
>anywhere you use MAP_ANON, and needs something along the following
>lines instead of the BSD sysctl:
>
>  int fd = open("/dev/urandom", O_RDONLY);
>  if (fd == -1) {
>    __libc_fatal("failed to open \"/dev/urandom\": %s", strerror(errno));
>  }
>  ssize_t bytes_read = TEMP_FAILURE_RETRY(read(fd, rnd, sizeof(rnd)));
>  if (bytes_read != sizeof(rnd)) {
>    __libc_fatal("couldn't read %zu bytes from \"/dev/urandom\": %s",
>sizeof(rnd), strerror(errno));
>  }
>  close(fd);

The base arc4random() now relies on MAP_INHERIT_ZERO support in the
minherit() system call, this it can avoid the getpid() check.

-portable arc4random will not follow this lineage.  -portable will
require a tweaked arc4random, based on 1.33

Reply via email to