stdlib: Fix __getrandom_nocancel type and arc4random usage (BZ #29638)
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 29 Sep 2022 19:15:20 +0000 (16:15 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Fri, 30 Sep 2022 18:24:49 +0000 (15:24 -0300)
Using an unsigned type prevents the fallback to be used if kernel
does not support getrandom syscall.

Checked on x86_64-linux-gnu.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
stdlib/arc4random.c
sysdeps/unix/sysv/linux/not-cancel.h

index e417ef6..960a38f 100644 (file)
@@ -34,7 +34,7 @@ void
 __arc4random_buf (void *p, size_t n)
 {
   static int seen_initialized;
-  size_t l;
+  ssize_t l;
   int fd;
 
   if (n == 0)
index a263d29..cf35c8b 100644 (file)
@@ -68,7 +68,7 @@ __writev_nocancel_nostatus (int fd, const struct iovec *iov, int iovcnt)
   INTERNAL_SYSCALL_CALL (writev, fd, iov, iovcnt);
 }
 
-static inline int
+static inline ssize_t
 __getrandom_nocancel (void *buf, size_t buflen, unsigned int flags)
 {
   return INLINE_SYSCALL_CALL (getrandom, buf, buflen, flags);