diff --git a/XML/Makefile b/XML/Makefile index 456c8256d..7f4ba2c96 100644 --- a/XML/Makefile +++ b/XML/Makefile @@ -8,7 +8,7 @@ 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 \ AttributesImpl CDATASection CharacterData ChildNodesList Comment \ diff --git a/XML/src/xmlparse.cpp b/XML/src/xmlparse.cpp index 887effc82..26797bead 100644 --- a/XML/src/xmlparse.cpp +++ b/XML/src/xmlparse.cpp @@ -7,12 +7,19 @@ #include #include /* 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 /* gettimeofday() */ #include /* getpid() */ #include /* 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(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) {