about summary refs log tree commit diff
path: root/sysdeps/mach/hurd
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2022-09-29 16:18:06 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2022-09-30 15:25:15 -0300
commit609c9d0951da387cd523b5db42a82d38dabc37c4 (patch)
treea9f4e664f78c4d4870d479db5ef467519d015137 /sysdeps/mach/hurd
parent13db9ee2cb3b77e25f852be7d6952882e1be6f00 (diff)
downloadglibc-609c9d0951da387cd523b5db42a82d38dabc37c4.tar.gz
glibc-609c9d0951da387cd523b5db42a82d38dabc37c4.tar.xz
glibc-609c9d0951da387cd523b5db42a82d38dabc37c4.zip
malloc: Do not clobber errno on __getrandom_nocancel (BZ #29624)
Use INTERNAL_SYSCALL_CALL instead of INLINE_SYSCALL_CALL.  This
requires emulate the semantic for hurd call (so __arc4random_buf
uses the fallback).

Checked on x86_64-linux-gnu.

Reviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>
Diffstat (limited to 'sysdeps/mach/hurd')
-rw-r--r--sysdeps/mach/hurd/not-cancel.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/sysdeps/mach/hurd/not-cancel.h b/sysdeps/mach/hurd/not-cancel.h
index ae58b734e3..e2edfb1cf3 100644
--- a/sysdeps/mach/hurd/not-cancel.h
+++ b/sysdeps/mach/hurd/not-cancel.h
@@ -25,6 +25,7 @@
 #include <sys/wait.h>
 #include <time.h>
 #include <sys/uio.h>
+#include <sys/random.h>
 #include <hurd.h>
 #include <hurd/fd.h>
 
@@ -75,8 +76,15 @@ __typeof (__fcntl) __fcntl_nocancel;
 #define __fcntl64_nocancel(...) \
   __fcntl_nocancel (__VA_ARGS__)
 
-#define __getrandom_nocancel(buf, size, flags) \
-  __getrandom (buf, size, flags)
+static inline ssize_t
+__getrandom_nocancel (void *buf, size_t buflen, unsigned int flags)
+{
+  int save_errno = errno;
+  ssize_t r = __getrandom (buf, buflen, flags);
+  r = r == -1 ? -errno : r;
+  __set_errno (save_errno);
+  return r;
+}
 
 #define __poll_infinity_nocancel(fds, nfds) \
   __poll (fds, nfds, -1)