mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-26 18:42:41 +01:00
expat cross-platform fixes
This commit is contained in:
@@ -7,12 +7,19 @@
|
||||
#include <assert.h>
|
||||
#include <limits.h> /* UINT_MAX */
|
||||
|
||||
#ifdef _WIN32
|
||||
#define getpid GetCurrentProcessId
|
||||
#define EXPAT_POCO 1
|
||||
|
||||
#if defined(EXPAT_POCO)
|
||||
#include "Poco/Process.h"
|
||||
#include "Poco/Timestamp.h"
|
||||
#define platform_getpid Poco::Process::id
|
||||
#elif defined(_WIN32)
|
||||
#define platform_getpid GetCurrentProcessId
|
||||
#else
|
||||
#include <sys/time.h> /* gettimeofday() */
|
||||
#include <sys/types.h> /* getpid() */
|
||||
#include <unistd.h> /* getpid() */
|
||||
#define platform_getpid getpid
|
||||
#endif
|
||||
|
||||
#define XML_BUILDING_EXPAT 1
|
||||
@@ -703,9 +710,11 @@ static const XML_Char implicitContext[] = {
|
||||
};
|
||||
|
||||
static unsigned long
|
||||
gather_time_entropy(void)
|
||||
platform_gather_time_entropy(void)
|
||||
{
|
||||
#ifdef WIN32
|
||||
#if defined(EXPAT_POCO)
|
||||
return static_cast<unsigned long>(Poco::Timestamp().utcTime());
|
||||
#elif defined(_WIN32)
|
||||
FILETIME ft;
|
||||
GetSystemTimeAsFileTime(&ft); /* never fails */
|
||||
return ft.dwHighDateTime ^ ft.dwLowDateTime;
|
||||
@@ -727,7 +736,7 @@ generate_hash_secret_salt(XML_Parser parser)
|
||||
/* Process ID is 0 bits entropy if attacker has local access
|
||||
* XML_Parser address is few bits of entropy if attacker has local access */
|
||||
const unsigned long entropy =
|
||||
gather_time_entropy() ^ getpid() ^ (unsigned long)parser;
|
||||
platform_gather_time_entropy() ^ platform_getpid() ^ (unsigned long)parser;
|
||||
|
||||
/* Factors are 2^31-1 and 2^61-1 (Mersenne primes M31 and M61) */
|
||||
if (sizeof(unsigned long) == 4) {
|
||||
|
||||
Reference in New Issue
Block a user