mirror of
git://sourceware.org/git/glibc.git
synced 2025-04-24 14:41:06 +08:00
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>
This commit is contained in:
parent
13db9ee2cb
commit
609c9d0951
@ -51,7 +51,7 @@ __arc4random_buf (void *p, size_t n)
|
|||||||
n -= l;
|
n -= l;
|
||||||
continue; /* Interrupted by a signal; keep going. */
|
continue; /* Interrupted by a signal; keep going. */
|
||||||
}
|
}
|
||||||
else if (l < 0 && errno == ENOSYS)
|
else if (l == -ENOSYS)
|
||||||
break; /* No syscall, so fallback to /dev/urandom. */
|
break; /* No syscall, so fallback to /dev/urandom. */
|
||||||
arc4random_getrandom_failure ();
|
arc4random_getrandom_failure ();
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
|
#include <sys/random.h>
|
||||||
#include <hurd.h>
|
#include <hurd.h>
|
||||||
#include <hurd/fd.h>
|
#include <hurd/fd.h>
|
||||||
|
|
||||||
@ -75,8 +76,15 @@ __typeof (__fcntl) __fcntl_nocancel;
|
|||||||
#define __fcntl64_nocancel(...) \
|
#define __fcntl64_nocancel(...) \
|
||||||
__fcntl_nocancel (__VA_ARGS__)
|
__fcntl_nocancel (__VA_ARGS__)
|
||||||
|
|
||||||
#define __getrandom_nocancel(buf, size, flags) \
|
static inline ssize_t
|
||||||
__getrandom (buf, size, flags)
|
__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) \
|
#define __poll_infinity_nocancel(fds, nfds) \
|
||||||
__poll (fds, nfds, -1)
|
__poll (fds, nfds, -1)
|
||||||
|
@ -71,7 +71,7 @@ __writev_nocancel_nostatus (int fd, const struct iovec *iov, int iovcnt)
|
|||||||
static inline ssize_t
|
static inline ssize_t
|
||||||
__getrandom_nocancel (void *buf, size_t buflen, unsigned int flags)
|
__getrandom_nocancel (void *buf, size_t buflen, unsigned int flags)
|
||||||
{
|
{
|
||||||
return INLINE_SYSCALL_CALL (getrandom, buf, buflen, flags);
|
return INTERNAL_SYSCALL_CALL (getrandom, buf, buflen, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user