[PATCH v1] miscutils/seedrng.c: fix <sys/random.h> include error on glibc < 2.25
alice
alice at ayaya.dev
Fri Feb 17 18:50:06 UTC 2023
On Fri Feb 17, 2023 at 7:39 PM CET, Thomas Devoogdt wrote:
> From: Thomas Devoogdt <thomas.devoogdt at barco.com>
>
> getrandom() was introduced in version 3.17 of the Linux kernel.
> Support was added to glibc in version 2.25.
>
> https://man7.org/linux/man-pages/man2/getrandom.2.html
>
> read_new_seed will anyway fallback to /dev/{u}random if (ret != len)
>
> Signed-off-by: Thomas Devoogdt <thomas.devoogdt at barco.com>
> ---
> miscutils/seedrng.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/miscutils/seedrng.c b/miscutils/seedrng.c
> index 967741dc7..663fb47a4 100644
> --- a/miscutils/seedrng.c
> +++ b/miscutils/seedrng.c
> @@ -42,9 +42,14 @@
> #include "libbb.h"
>
> #include <linux/random.h>
> -#include <sys/random.h>
> #include <sys/file.h>
>
> +#if __GLIBC_PREREQ(2, 25)
iirc this macro is not portable, you have to first check if it is defined, no?
> +#include <sys/random.h>
> +#else
> +#define getrandom(buf, len, flags) (-1)
> +#endif
> +
> #ifndef GRND_INSECURE
> #define GRND_INSECURE 0x0004 /* Apparently some headers don't ship with this yet. */
> #endif
> --
> 2.39.0
More information about the busybox
mailing list