|
| 1 | +Upstream-Status: Backport |
| 2 | + |
| 3 | +Signed-off-by: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com> |
| 4 | +--- |
| 5 | +From 80fb001240ed0c30f06eabc75a7899bf1067f515 Mon Sep 17 00:00:00 2001 |
| 6 | +From: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com> |
| 7 | +Date: Wed, 27 Jan 2021 00:09:41 +0000 |
| 8 | +Subject: [PATCH] RandBytes: Stop including sys/random.h on Linux. |
| 9 | + |
| 10 | +We use the getrandom() syscall via LSS, so the header is not necessary. |
| 11 | +Additionally, this file might be built on host toolchains with very old |
| 12 | +packages (e.g. CentOS 7 cross-compiling to a more recent target) where the |
| 13 | +header might not exist (due to glibc and/or the Linux kernel version being |
| 14 | +too old), but where reading from /dev/urandom should still work. |
| 15 | + |
| 16 | +Replicate the #ifdef checks from RandBytes() itself in the includes to make |
| 17 | +the file build in more systems. |
| 18 | + |
| 19 | +Bug: 995996 |
| 20 | +Change-Id: If75d706f51bed2f0239ec15ca82d2f58d1055b05 |
| 21 | +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2644955 |
| 22 | +Reviewed-by: Chris Palmer <palmer@chromium.org> |
| 23 | +Commit-Queue: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com> |
| 24 | +Cr-Commit-Position: refs/heads/master@{#847397} |
| 25 | +--- |
| 26 | + base/rand_util_posix.cc | 6 ++---- |
| 27 | + 1 file changed, 2 insertions(+), 4 deletions(-) |
| 28 | + |
| 29 | +diff --git a/base/rand_util_posix.cc b/base/rand_util_posix.cc |
| 30 | +index f121db7fcbdf..b58c37406214 100644 |
| 31 | +--- a/base/rand_util_posix.cc |
| 32 | ++++ b/base/rand_util_posix.cc |
| 33 | +@@ -17,11 +17,9 @@ |
| 34 | + #include "base/posix/eintr_wrapper.h" |
| 35 | + #include "build/build_config.h" |
| 36 | + |
| 37 | +-#if defined(OS_LINUX) || defined(OS_CHROMEOS) |
| 38 | ++#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && !defined(OS_NACL) |
| 39 | + #include "third_party/lss/linux_syscall_support.h" |
| 40 | +-#endif |
| 41 | +- |
| 42 | +-#if !defined(OS_IOS) && !defined(OS_NACL) |
| 43 | ++#elif defined(OS_MAC) |
| 44 | + // TODO(crbug.com/995996): Waiting for this header to appear in the iOS SDK. |
| 45 | + // (See below.) |
| 46 | + #include <sys/random.h> |
| 47 | +-- |
| 48 | +2.29.2 |
| 49 | + |
0 commit comments