[PATCH] D90627: [sanitizer] Assume getrandom might not be supported by the kernel

Adhemerval Zanella via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 2 09:51:28 PST 2020


zatrazz created this revision.
zatrazz added reviewers: kcc, dvyukov.
zatrazz added a project: Sanitizers.
Herald added a subscriber: Sanitizers.
zatrazz requested review of this revision.

It was added on kernel 3.17.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90627

Files:
  compiler-rt/test/sanitizer_common/TestCases/Posix/getrandom.c


Index: compiler-rt/test/sanitizer_common/TestCases/Posix/getrandom.c
===================================================================
--- compiler-rt/test/sanitizer_common/TestCases/Posix/getrandom.c
+++ compiler-rt/test/sanitizer_common/TestCases/Posix/getrandom.c
@@ -3,6 +3,7 @@
 //
 
 #include <sys/types.h>
+#include <errno.h>
 
 #if !defined(__GLIBC_PREREQ)
 #define __GLIBC_PREREQ(a, b) 0
@@ -21,6 +22,8 @@
   ssize_t n = 1;
 #if defined(HAS_GETRANDOM)
   n = getrandom(buf, sizeof(buf), 0);
+  if (n == -1 && errno == ENOSYS)
+    n = 1;
 #endif
   return (int)(n <= 0);
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90627.302321.patch
Type: text/x-patch
Size: 585 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201102/2a122aaa/attachment.bin>


More information about the llvm-commits mailing list