0005-seedrng-fix-for-glibc-2.24-not-providing-getrandom.patch 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. From 200a9669fbf6f06894e4243cccc9fc11a1a6073a Mon Sep 17 00:00:00 2001
  2. From: Denys Vlasenko <vda.linux@googlemail.com>
  3. Date: Mon, 10 Apr 2023 17:26:04 +0200
  4. Subject: [PATCH] seedrng: fix for glibc <= 2.24 not providing getrandom()
  5. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
  6. Upstream: https://git.busybox.net/busybox/commit/?id=200a9669fbf6f06894e4243cccc9fc11a1a6073a
  7. ---
  8. miscutils/seedrng.c | 14 ++++++++++++++
  9. 1 file changed, 14 insertions(+)
  10. diff --git a/miscutils/seedrng.c b/miscutils/seedrng.c
  11. index 967741dc7..7cc855141 100644
  12. --- a/miscutils/seedrng.c
  13. +++ b/miscutils/seedrng.c
  14. @@ -45,6 +45,20 @@
  15. #include <sys/random.h>
  16. #include <sys/file.h>
  17. +/* Fix up glibc <= 2.24 not having getrandom() */
  18. +#if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ <= 24
  19. +#include <sys/syscall.h>
  20. +# define getrandom(...) bb_getrandom(__VA_ARGS__)
  21. +static ssize_t getrandom(void *buffer, size_t length, unsigned flags)
  22. +{
  23. +# if defined(__NR_getrandom)
  24. + return syscall(__NR_getrandom, buffer, length, flags);
  25. +# else
  26. + return ENOSYS;
  27. +# endif
  28. +}
  29. +#endif
  30. +
  31. #ifndef GRND_INSECURE
  32. #define GRND_INSECURE 0x0004 /* Apparently some headers don't ship with this yet. */
  33. #endif
  34. --
  35. 2.39.1