Skip to content

Fix wrong epoch formatting for verbose mmdblookup#143

Merged
horgh merged 1 commit intomaxmind:masterfrom
rainerjung:mmdblookup-time_t-32bit
Jun 26, 2017
Merged

Fix wrong epoch formatting for verbose mmdblookup#143
horgh merged 1 commit intomaxmind:masterfrom
rainerjung:mmdblookup-time_t-32bit

Conversation

@rainerjung
Copy link
Contributor

(at least on 32 bit builds on Solaris Sparc).

Verbose mmdblookup output before the fix:
Build epoch: 1497876636 (1970-01-01 00:00:00 UTC)
and after the fix:
Build epoch: 1497876636 (2017-06-19 12:50:36 UTC)

The original code converted *uint64_t to *time_t by casting
the pointer. But that doesn't convert the referenced value
and for a build where a time_t is a long of size 32bits
(eg. on Solaris Sparc) probably also depending on endianess
when dereferencing the casted pointer you get the wrong half
of the 64 bits (=0).

The fix is to cast the value and use a pointer to the casted value.

(at least on 32 bit builds on Solaris Sparc).

Verbose mmdblookup output before the fix:
   Build epoch:   1497876636 (1970-01-01 00:00:00 UTC)
and after the fix:
   Build epoch:   1497876636 (2017-06-19 12:50:36 UTC)

The original code converted *uint64_t to *time_t by casting
the pointer. But that doesn't convert the referenced value
and for a build where a time_t is a long of size 32bits
(eg. on Solaris Sparc) probably also depending on endianess
when dereferencing the casted pointer you get the wrong half
of the 64 bits (=0).

The fix is to cast the value and use a pointer to the casted value.
@oschwald oschwald requested a review from horgh June 26, 2017 20:54
@horgh horgh merged commit 4c2a864 into maxmind:master Jun 26, 2017
@horgh
Copy link
Contributor

horgh commented Jun 26, 2017

Hi again @rainerjung.

Thanks for the fix. Nice one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants