[PATCH] D50937: [Sanitizer] implementing remaining function under OSX

Kuba (Brecka) Mracek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 24 09:13:36 PDT 2018


kubamracek added inline comments.


================
Comment at: lib/sanitizer_common/sanitizer_mac.cc:1069-1086
+  if (!buffer || !length || length > 256)
+    return false;
+  uptr rnd = syscall(SYS_getentropy, buffer, length);
+  int rverrno = 0;
+  if (internal_iserror(rnd, &rverrno) && rverrno == EINVAL)
+    return false;
+  else if (rnd == 0)
----------------
devnexen wrote:
> kubamracek wrote:
> > Can we just replace all of this with a call to `arc4random_buf`?
> We could even though arc4random* does not necessarily has similar usage and also to be "api" compatible with other implementations (i.e buffer limit and so on).
I'd prefer to use arc4random here. We shouldn't be using syscalls on Darwin, and arc4random seems to do exactly the same, but is a nice API.


https://reviews.llvm.org/D50937





More information about the llvm-commits mailing list