Skip to content

Commit

Permalink
Address 64bit MinGW compile warning (fixes #15)
Browse files Browse the repository at this point in the history
../../../xmlparse.c: In function ‘generate_hash_secret_salt’:
../../../xmlparse.c:725:42: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
       gather_time_entropy() ^ getpid() ^ (unsigned long)parser;
                                          ^

Thanks to Viktor Szakats.
  • Loading branch information
hartwork committed Mar 16, 2017
1 parent ff9cf99 commit 863c430
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions expat/Changes
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Release ??????????
Rhodri James
Sergei Nikulov
Tobias Taschner
Viktor Szakats

Release 2.2.0 Tue June 21 2016
Security fixes:
Expand Down
10 changes: 9 additions & 1 deletion expat/lib/xmlparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,14 @@ gather_time_entropy(void)
static unsigned long
generate_hash_secret_salt(XML_Parser parser)
{
#if defined(__UINTPTR_TYPE__)
# define PARSER_CAST(p) (__UINTPTR_TYPE__)(p)
#elif defined(_WIN64) && defined(_MSC_VER)
# define PARSER_CAST(p) (unsigned __int64)(p)
#else
# define PARSER_CAST(p) (p)
#endif

#ifdef __CloudABI__
unsigned long entropy;
(void)parser;
Expand All @@ -729,7 +737,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;
gather_time_entropy() ^ getpid() ^ (unsigned long)PARSER_CAST(parser);

/* Factors are 2^31-1 and 2^61-1 (Mersenne primes M31 and M61) */
if (sizeof(unsigned long) == 4) {
Expand Down

0 comments on commit 863c430

Please sign in to comment.