[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH v1] miscutils/seedrng.c: fix <sys/random.h> include error on glibc < 2.25
From: "alice" <alice () ayaya ! dev>
Date: 2023-02-17 18:50:06
Message-ID: CQL2APSLA2HU.29BE0JV624A6Z () sumire
[Download RAW message or body]
On Fri Feb 17, 2023 at 7:39 PM CET, Thomas Devoogdt wrote:
> From: Thomas Devoogdt <thomas.devoogdt@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@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
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic