* NEWS: Mention the bug fix. * gl/lib/randread.c (get_nonce): Limit getrandom() <= 1024 bytes. --- NEWS | 4 ++++ gl/lib/randread.c | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS index a104c97a2..153bd5d59 100644 --- a/NEWS +++ b/NEWS @@ -51,6 +51,10 @@ GNU coreutils NEWS -*- outline -*- 'pr --length=1 --double-space' no longer enters an infinite loop. [This bug was present in "the beginning".] + shred again operates on Solaris when built for 64 bits. + Previously it would have exited with a "getrandom: Invalid argument" error. + [bug introduced in coreutils-9.0] + tac now handles short reads on its input. Previously it may have exited erroneously, especially with large input files with no separators. [This bug was present in "the beginning".] diff --git a/gl/lib/randread.c b/gl/lib/randread.c index 9c572951d..b729fedbc 100644 --- a/gl/lib/randread.c +++ b/gl/lib/randread.c @@ -132,7 +132,13 @@ get_nonce (void *buffer, size_t bufsize) char *buf = buffer, *buflim = buf + bufsize; while (buf < buflim) { - ssize_t nbytes = getrandom (buf, buflim - buf, 0); +#if defined __sun +# define MAX_GETRANDOM 1024 +#else +# define MAX_GETRANDOM SIZE_MAX +#endif + size_t max_bytes = MIN (buflim - buf, MAX_GETRANDOM); + ssize_t nbytes = getrandom (buf, max_bytes, 0); if (0 <= nbytes) buf += nbytes; else if (errno != EINTR) -- 2.41.0