From 609c9d0951da387cd523b5db42a82d38dabc37c4 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Thu, 29 Sep 2022 16:18:06 -0300 Subject: 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 --- sysdeps/mach/hurd/not-cancel.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'sysdeps/mach/hurd') 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 #include #include +#include #include #include @@ -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) -- cgit 1.4.1