mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-17 23:23:47 +02:00
expat cross-platform fixes
This commit is contained in:
parent
0e19cea0fb
commit
ba52ed967e
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
include $(POCO_BASE)/build/rules/global
|
include $(POCO_BASE)/build/rules/global
|
||||||
|
|
||||||
COMMONFLAGS += -DXML_NS -DXML_DTD -DHAVE_EXPAT_CONFIG_H
|
COMMONFLAGS += -DXML_NS -DXML_DTD -DHAVE_EXPAT_CONFIG_H -DEXPAT_POCO
|
||||||
|
|
||||||
objects = AbstractContainerNode AbstractNode Attr AttrMap Attributes \
|
objects = AbstractContainerNode AbstractNode Attr AttrMap Attributes \
|
||||||
AttributesImpl CDATASection CharacterData ChildNodesList Comment \
|
AttributesImpl CDATASection CharacterData ChildNodesList Comment \
|
||||||
|
@ -7,12 +7,19 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <limits.h> /* UINT_MAX */
|
#include <limits.h> /* UINT_MAX */
|
||||||
|
|
||||||
#ifdef _WIN32
|
#define EXPAT_POCO 1
|
||||||
#define getpid GetCurrentProcessId
|
|
||||||
|
#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
|
#else
|
||||||
#include <sys/time.h> /* gettimeofday() */
|
#include <sys/time.h> /* gettimeofday() */
|
||||||
#include <sys/types.h> /* getpid() */
|
#include <sys/types.h> /* getpid() */
|
||||||
#include <unistd.h> /* getpid() */
|
#include <unistd.h> /* getpid() */
|
||||||
|
#define platform_getpid getpid
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define XML_BUILDING_EXPAT 1
|
#define XML_BUILDING_EXPAT 1
|
||||||
@ -703,9 +710,11 @@ static const XML_Char implicitContext[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static unsigned long
|
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;
|
FILETIME ft;
|
||||||
GetSystemTimeAsFileTime(&ft); /* never fails */
|
GetSystemTimeAsFileTime(&ft); /* never fails */
|
||||||
return ft.dwHighDateTime ^ ft.dwLowDateTime;
|
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
|
/* Process ID is 0 bits entropy if attacker has local access
|
||||||
* XML_Parser address is few bits of entropy if attacker has local access */
|
* XML_Parser address is few bits of entropy if attacker has local access */
|
||||||
const unsigned long entropy =
|
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) */
|
/* Factors are 2^31-1 and 2^61-1 (Mersenne primes M31 and M61) */
|
||||||
if (sizeof(unsigned long) == 4) {
|
if (sizeof(unsigned long) == 4) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user