Rearrange RNG code slightly
In preparation of exporting getentropy/getrandom to userspace, rearrange code a bit: - Define RtlGenRandom in ntdll.h. - Drop calls to getentropy in favor of RtlGenRandom (fhandler_socket, fhandler_dev_random). - Add try/except blocks in fhandler_dev_random to return EFAULT rather than crashing if buffer pointer is invalid. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
@@ -233,12 +233,6 @@ check_iovec (const struct iovec *iov, int iovcnt, bool forwrite)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* There's a bug in ntsecapi.h (Mingw as well as MSFT). SystemFunction036
|
||||
is, in fact, a WINAPI function, but it's not defined as such. Therefore
|
||||
we have to do it correctly here. */
|
||||
#define RtlGenRandom SystemFunction036
|
||||
extern "C" BOOLEAN WINAPI RtlGenRandom (PVOID, ULONG);
|
||||
|
||||
/* Used by arc2random, fhandler_socket and fhandler_random. */
|
||||
extern "C" int
|
||||
getentropy (void *ptr, size_t len)
|
||||
|
Reference in New Issue
Block a user