blob: 80f65eda567b04110de074ee94b936a667f065a1 [file] [log] [blame]
This patch removes calls to getentropy() and BCryptGetRandom() because they
aren't implemented or supported on certain platforms based on the trybot
results I saw. I will try upstreaming a configure script flag soon to replace
this patch file. This patch is safe because it reverts the random number
generation behavior before a recent libxml upstream patch.
diff --git a/dict.c b/dict.c
index c843bb7b..96435d52 100644
--- a/dict.c
+++ b/dict.c
@@ -909,17 +909,12 @@ xmlDictQLookup(xmlDictPtr dict, const xmlChar *prefix, const xmlChar *name) {
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
- #include <bcrypt.h>
#elif defined(HAVE_GETENTROPY)
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
- #ifdef HAVE_SYS_RANDOM_H
- #include <sys/random.h>
- #endif
-#else
- #include <time.h>
#endif
+#include <time.h>
static xmlMutex xmlRngMutex;
@@ -931,29 +926,6 @@ xmlInitRandom(void) {
xmlInitMutex(&xmlRngMutex);
{
-#ifdef _WIN32
- NTSTATUS status;
-
- status = BCryptGenRandom(NULL, (unsigned char *) globalRngState,
- sizeof(globalRngState),
- BCRYPT_USE_SYSTEM_PREFERRED_RNG);
- if (!BCRYPT_SUCCESS(status)) {
- fprintf(stderr, "libxml2: BCryptGenRandom failed with "
- "error code %lu\n", GetLastError());
- abort();
- }
-#elif defined(HAVE_GETENTROPY)
- while (1) {
- if (getentropy(globalRngState, sizeof(globalRngState)) == 0)
- break;
-
- if (errno != EINTR) {
- fprintf(stderr, "libxml2: getentropy failed with "
- "error code %d\n", errno);
- abort();
- }
- }
-#else
int var;
globalRngState[0] =
@@ -962,7 +934,6 @@ xmlInitRandom(void) {
globalRngState[1] =
HASH_ROL((unsigned) ((size_t) &xmlRngMutex & 0xFFFFFFFF), 16) ^
HASH_ROL((unsigned) ((size_t) &var & 0xFFFFFFFF), 24);
-#endif
}
}