From e7f8d60323ae7368b84bc79930e37de6b195ba28 Mon Sep 17 00:00:00 2001 From: David Dick Date: Sat, 8 Feb 2025 20:00:28 +1100 Subject: [PATCH] Solaris getrandom apparently cannot cope with a parameter of 0 --- URandom.xs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/URandom.xs b/URandom.xs index c39dc3b..bfeccbc 100644 --- a/URandom.xs +++ b/URandom.xs @@ -39,6 +39,11 @@ crypt_urandom_getrandom(length) int result; CODE: Newx(data, length + 1u, char); +#if defined(__sun) && defined(__SVR4) + if (length == 0) { + result = 0; + } else { +#endif GETRANDOM: #ifdef HAVE_CRYPT_URANDOM_NATIVE_GETRANDOM result = getrandom(data, length, GRND_NONBLOCK); @@ -72,6 +77,9 @@ crypt_urandom_getrandom(length) croak("Failed to getrandom:%s", strerror(errno)); } } +#if defined(__sun) && defined(__SVR4) + } +#endif data[result] = '\0'; RETVAL = newSVpv(data, result); Safefree(data);